Run a function in an asyncio loop if any current drivers might need it. This function is used for provisioning features that take place outside of a specific database driver being selected, so if the current driver that happens to be used for the provisioning operation is an async d
(fn, *args, **kwargs)
| 52 | |
| 53 | |
| 54 | def _maybe_async_provisioning(fn, *args, **kwargs): |
| 55 | """Run a function in an asyncio loop if any current drivers might need it. |
| 56 | |
| 57 | This function is used for provisioning features that take |
| 58 | place outside of a specific database driver being selected, so if the |
| 59 | current driver that happens to be used for the provisioning operation |
| 60 | is an async driver, it will run in asyncio and not fail. |
| 61 | |
| 62 | Note that for blocking IO database drivers, this means they block the |
| 63 | event loop. |
| 64 | |
| 65 | """ |
| 66 | if not ENABLE_ASYNCIO: |
| 67 | return fn(*args, **kwargs) |
| 68 | |
| 69 | if config.any_async: |
| 70 | return _async_util.run_in_greenlet(fn, *args, **kwargs) |
| 71 | else: |
| 72 | return fn(*args, **kwargs) |
| 73 | |
| 74 | |
| 75 | def _maybe_async(fn, *args, **kwargs): |
nothing calls this directly
no test coverage detected