2020-04-27 11:02:00 -05:00
|
|
|
import asyncio
|
|
|
|
from functools import wraps
|
|
|
|
|
|
|
|
|
2018-09-22 02:41:44 -05:00
|
|
|
class AsyncClass:
|
|
|
|
async def do_coroutine(self):
|
|
|
|
"""A documented coroutine function"""
|
2022-08-28 14:03:17 -05:00
|
|
|
attr_coro_result = await _other_coro_func()
|
2018-09-22 02:41:44 -05:00
|
|
|
|
2020-02-21 09:28:35 -06:00
|
|
|
@classmethod
|
|
|
|
async def do_coroutine2(cls):
|
|
|
|
"""A documented coroutine classmethod"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
async def do_coroutine3():
|
|
|
|
"""A documented coroutine staticmethod"""
|
|
|
|
pass
|
|
|
|
|
2021-09-16 12:19:34 -05:00
|
|
|
async def do_asyncgen(self):
|
|
|
|
"""A documented async generator"""
|
|
|
|
yield
|
|
|
|
|
2018-09-22 02:41:44 -05:00
|
|
|
|
|
|
|
async def _other_coro_func():
|
|
|
|
return "run"
|
2020-04-27 11:02:00 -05:00
|
|
|
|
|
|
|
|
|
|
|
def myawait(f):
|
|
|
|
@wraps(f)
|
|
|
|
def wrapper(*args, **kwargs):
|
|
|
|
awaitable = f(*args, **kwargs)
|
|
|
|
return asyncio.run(awaitable)
|
|
|
|
return wrapper
|
|
|
|
|
|
|
|
|
|
|
|
sync_func = myawait(_other_coro_func)
|