2020-04-28 01:02:00 +09:00
|
|
|
import asyncio
|
|
|
|
|
from functools import wraps
|
|
|
|
|
|
|
|
|
|
|
2018-09-22 16:41:44 +09:00
|
|
|
class AsyncClass:
|
|
|
|
|
async def do_coroutine(self):
|
|
|
|
|
"""A documented coroutine function"""
|
|
|
|
|
attr_coro_result = await _other_coro_func() # NOQA
|
|
|
|
|
|
2020-02-22 00:28:35 +09:00
|
|
|
@classmethod
|
|
|
|
|
async def do_coroutine2(cls):
|
|
|
|
|
"""A documented coroutine classmethod"""
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
async def do_coroutine3():
|
|
|
|
|
"""A documented coroutine staticmethod"""
|
|
|
|
|
pass
|
|
|
|
|
|
2018-09-22 16:41:44 +09:00
|
|
|
|
|
|
|
|
async def _other_coro_func():
|
|
|
|
|
return "run"
|
2020-04-28 01:02:00 +09: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)
|