blob: b42b366aa96485cea62e738ead5855b6321aa99f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
"""
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
|