def time(self): """Return the time according to the event loop's clock. This is a float expressed in seconds since an epoch, but the epoch, precision, accuracy and drift are unspecified and may differ per event loop. """ return monotonic()
def __call__(self): loop = global_event_loop() result = loop.create_future() remaining = self._succeed_time - monotonic() if remaining > 0: loop.call_soon_threadsafe(lambda: None if result.done() else result.set_exception(SucceedLaterException( 'time until success: {} seconds'.format(remaining)))) else: loop.call_soon_threadsafe(lambda: None if result.done() else result.set_result('success')) return result
def __call__(self): loop = global_event_loop() result = loop.create_future() remaining = self._succeed_time - monotonic() if remaining > 0: loop.call_soon_threadsafe( lambda: None if result.done() else result.set_exception( SucceedLaterException('time until success: {} seconds'. format(remaining)))) else: loop.call_soon_threadsafe(lambda: None if result.done() else result .set_result('success')) return result
def __call__(self): remaining = self._succeed_time - monotonic() if remaining > 0: raise SucceedLaterException( 'time until success: {} seconds'.format(remaining)) return 'success'
def __init__(self, duration): self._succeed_time = monotonic() + duration
def __call__(self): remaining = self._succeed_time - monotonic() if remaining > 0: raise SucceedLaterException('time until success: {} seconds'.format(remaining)) return 'success'