[svn r111] add ready() method to event class, so you can tell in advance whether or not wait() is going to block.
This commit is contained in:
@@ -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.
|
||||
|
Reference in New Issue
Block a user