def wait(self, timeout=None): if timeout is not None: bailout = time.time() + timeout abstime = pthread.timespec() abstime.tv_sec = int(bailout) abstime.tv_nsec = int((bailout - int(bailout)) * (10 ** 9)) return self.__cond.timedwait(abstime) else: return self.__cond.wait()
def wait(self, timeout=None): if timeout is not None: bailout = time.time() + timeout abstime = pthread.timespec() abstime.tv_sec = int(bailout) abstime.tv_nsec = int((bailout - int(bailout)) * (10**9)) return self.__cond.timedwait(abstime) else: return self.__cond.wait()
def _wait_timeout(self, timeout): bailout = time.time() + timeout abstime = pthread.timespec() abstime.tv_sec = int(bailout) abstime.tv_nsec = int((bailout - int(bailout)) * (10 ** 9)) while True: if self.__cond.timedwait(abstime) == errno.ETIMEDOUT: break if self.__signals > 0: self.__signals -= 1 break
def _wait_timeout(self, timeout): bailout = time.time() + timeout abstime = pthread.timespec() abstime.tv_sec = int(bailout) abstime.tv_nsec = int((bailout - int(bailout)) * (10**9)) while True: if self.__cond.timedwait(abstime) == errno.ETIMEDOUT: break if self.__signals > 0: self.__signals -= 1 break
def wait_until(self, bailout): """ Waits until bailout time has passed or the condtion is notified. This may return before bailout time if notify() or notify_all() were invoked, or because of spurious wakeup of the underlying implementation. You must check the return value to detect if bailout time has passed. Return True if bailout timeout has passed, False otherwise. """ abstime = pthread.timespec() abstime.tv_sec = int(bailout) abstime.tv_nsec = int((bailout - int(bailout)) * (10 ** 9)) return self.__cond.timedwait(abstime) == errno.ETIMEDOUT