Wrapper that attempts to convert blocking function into non-blocking if possible for asyncio use
(func, /, *args, **kwargs)
| 136 | |
| 137 | |
| 138 | async def non_blocking(func, /, *args, **kwargs): |
| 139 | """ |
| 140 | Wrapper that attempts to convert blocking function into non-blocking if possible for asyncio use |
| 141 | """ |
| 142 | if sys.version_info[1] >= 9: # Available only in py3.9+ |
| 143 | return await asyncio.to_thread(func, *args, **kwargs) |
| 144 | else: # Fallback, just call function directly in blocking mode |
| 145 | return func(*args, **kwargs) |
no test coverage detected