diff --git a/eventlet/coros.py b/eventlet/coros.py index b26eab8..cef72f9 100644 --- a/eventlet/coros.py +++ b/eventlet/coros.py @@ -95,6 +95,14 @@ class event(object): self.epoch = time.time() self._result = NOT_USED self._waiters = {} + + def ready(self): + """ Return true if the wait() call will return immediately. + Used to avoid waiting for things that might take a while to time out. + For example, you can put a bunch of events into a list, and then visit + them all repeatedly, calling ready() until one returns True, and then + you can wait() on that one.""" + return self._result is not NOT_USED def wait(self): """Wait until another coroutine calls send.