A greenlet that runs the event loop.
It is created automatically by get_hub().
Wait for the event loop to finish. Exits only when there are no more spawned greenlets, started servers, active timeouts or watchers.
If timeout is provided, wait no longer for the specified number of seconds.
Returns True if exited because the loop finished execution. Returns False if exited because of timeout expired.
Return the hub for the current thread.
If hub does not exists in the current thread, the new one is created with call to get_hub_class().
A low level communication utility for greenlets.
Wrapper around greenlet’s switch() and throw() calls that makes them somewhat safer:
The switch() and throw() methods must only be called from the Hub greenlet. The get() method must be called from a greenlet other than Hub.
>>> result = Waiter()
>>> timer = get_hub().loop.timer(0.1)
>>> timer.start(result.switch, 'hello from Waiter')
>>> result.get() # blocks for 0.1 seconds
'hello from Waiter'
If switch is called before the greenlet gets a chance to call get() then Waiter stores the value.
>>> result = Waiter()
>>> timer = get_hub().loop.timer(0.1)
>>> timer.start(result.switch, 'hi from Waiter')
>>> sleep(0.2)
>>> result.get() # returns immediatelly without blocking
'hi from Waiter'
Warning
This a limited and dangerous way to communicate between greenlets. It can easily leave a greenlet unscheduled forever if used incorrectly. Consider using safer Event/AsyncResult/Queue classes.