A greenlet that runs the event loop.
It is created automatically by get_hub().
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()
>>> _ = core.timer(0.1, 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()
>>> _ = core.timer(0.1, 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.