Example #1
0
 def WaitUntilAllPreviousMessagesHaveBeenHandled(self):
     lock: threading.Lock = threading.Lock()
     lock.acquire()
     # send dummy message to clear out pipe
     mesg = zmessage.Message(None, zmessage.LowestPriority(),
                             lambda _: lock.release(), None)
     self.SendMessage(mesg)
     # wait until semaphore is released by callback
     lock.acquire()
Example #2
0
    def Terminate(self):
        """
        Terminate shuts down the driver object.

        """
        lock = threading.Lock()
        lock.acquire()

        def cb(_):
            self._terminate = True
            lock.release()

        # send listeners signal to shutdown
        self._in_queue.put((time.time(), None))
        self.SendMessage(
            zmessage.Message(None, zmessage.LowestPriority(), cb, None))
        lock.acquire()
        logging.info("Driver terminated")