(*args, **kwargs)
| 104 | |
| 105 | @functools.wraps(func) |
| 106 | def wrapper(*args, **kwargs): |
| 107 | coro = func(*args, **kwargs) |
| 108 | |
| 109 | if not inspect.iscoroutine(coro): |
| 110 | return coro |
| 111 | |
| 112 | try: |
| 113 | loop = asyncio.get_running_loop() |
| 114 | except RuntimeError: |
| 115 | loop = None |
| 116 | |
| 117 | if loop and loop.is_running(): |
| 118 | return coro |
| 119 | else: |
| 120 | return asyncio.run(coro) |
| 121 | |
| 122 | return wrapper |