def disconnect(self): try: if current_thread() is not self._thread: self._queue.push(exit) self._thread.join(3.0) finally: Resource.disconnect(self)
def connect(self): Resource.connect(self) self._thread = LightThread(target = self._thread_proc, name = "{0:s}:?".format(self.name)) self._thread.start() self._ready.wait(3.0) # this may spend waiting slightly less, but it's ok if not self._ready.is_set(): self._queue.push(exit) # just in case the thread has in fact started raise Exception("new thread failed to start in 3.0 seconds")
def __init__(self, name, release): Resource.__init__(self, name) self._release = release self._ready, self._queue = Event(), InterlockedQueue() if __name__ == "__main__": self._timeout = Timeout(3.0) else: self._timeout = Timeout(60.0) self._count = 0
def _expired(self): return self._timeout.expired or Resource._expired(self)