MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _maybe_async_provisioning

Function _maybe_async_provisioning

lib/sqlalchemy/testing/asyncio.py:54–72  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

52
53
54def _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
75def _maybe_async(fn, *args, **kwargs):

Callers

nothing calls this directly

Calls 1

run_in_greenletMethod · 0.80

Tested by

no test coverage detected