Files
slixmpp/slixmpp/xmlstream/asyncio.py
mathieui a0a37c19ff Remove monkeypatching hack on the event loop
This allowed us to schedule events in-order later in the event loop, but
was detrimental to using other event loops and debugging.
2016-10-05 20:19:07 +02:00

23 lines
473 B
Python

"""
asyncio-related utilities
"""
import asyncio
from functools import wraps
def future_wrapper(func):
"""
Make sure the result of a function call is an asyncio.Future()
object.
"""
@wraps(func)
def wrapper(*args, **kwargs):
result = func(*args, **kwargs)
if isinstance(result, asyncio.Future):
return result
future = asyncio.Future()
future.set_result(result)
return future
return wrapper