blob: f977b6e77e3cb081e57984dbbc2fa0fa93b970b2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
import asyncio
from functools import wraps
class AsyncClass:
async def do_coroutine(self):
"""A documented coroutine function"""
attr_coro_result = await _other_coro_func()
@classmethod
async def do_coroutine2(cls):
"""A documented coroutine classmethod"""
pass
@staticmethod
async def do_coroutine3():
"""A documented coroutine staticmethod"""
pass
async def do_asyncgen(self):
"""A documented async generator"""
yield
async def _other_coro_func():
return "run"
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)
|