Age | Commit message (Collapse) | Author |
|
This allowed us to schedule events in-order later in the event loop, but
was detrimental to using other event loops and debugging.
|
|
remove coroutine_wrapper, add a future_wrapper (which is only needed
when the result stanza can be cached).
Update the documentation as well.
|
|
This decorator checks for the coroutine=True keyword arg and wraps the
result of the function call in a coroutine if it isn’t.
This allows to have constructs like:
@coroutine_wrapper
def toto(xmpp, *, coroutine=False):
if xmpp.cached:
return xmpp.cached
else:
return xmpp.make_iq_get().send(coroutine=coroutine)
@asyncio.coroutine
def main(xmpp):
result = yield from toto(xmpp, coroutine=True)
xmpp.cached = result
result2 = yield from toto(xmpp, coroutine=True)
If the wrapper wasn’t there, the second fetch would fail. This decorator
does not do anything if the coroutine argument is False.
|
|
|
|
|
|
We use some dirty monkey-patching to add a idle_call() function to the
asyncio module. We then use that method to handle each received stanza only
when the event loop is not busy with some other IO (mainly, the standard
input)
|