L irddlmZddlmZddlZddlmZddlmZdZ eZ d Z d Z d Z d Zd ZdZy)) annotations)wrapsN)config) _AsyncUtilTc,tjy)zcalled when the test finishesN) _async_utilclose`/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sqlalchemy/testing/asyncio.py _shutdownr#sr c4tj|g|i|SN)r runfnargskwargss r_run_coroutine_functionr(s ??2 / / //r cPts||i|Stj|g|i|S)aRun a function in an asyncio loop unconditionally. This function is used for provisioning features like testing a database connection for server info. Note that for blocking IO database drivers, this means they block the event loop. )ENABLE_ASYNCIOr run_in_greenletrs r _assume_asyncr,s2 4"6""  & &r ;D ;F ;;r cts||i|Stjrtj|g|i|S||i|S)aRun 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 driver, it will run in asyncio and not fail. Note that for blocking IO database drivers, this means they block the event loop. )rr any_asyncr rrs r_maybe_async_provisioningr=sK 4"6"" **2????4"6""r cts||i|Stjj}|rt j |g|i|S||i|S)zRun a function in an asyncio loop if the current selected driver is async. This function is used for test setup/teardown and tests themselves where the current DB driver is known. )rr_currentis_asyncr r)rrrr!s r _maybe_asyncr"RsT 4"6""''H**2????4"6""r ctjr&tfdtfd}|Stfd}|S)zApply the _maybe_async function to an existing function and return as a wrapped callable, supporting generator functions as well. This is currently used for pytest fixtures that support generator use. c> t|S#t$rcYSwxYwr)next StopIteration)gen_stops r call_nextz'_maybe_async_wrapper..call_nextqs& Cy     s  c?JK|i|} t|}|ury|wrr")rrr'valuer(r)rs r wrap_fixturez*_maybe_async_wrapper..wrap_fixturexs9d%f%C$Y4E> s #c"tg|i|Srr+)rrrs rr-z*_maybe_async_wrapper..wrap_fixtures4T4V4 4r )inspectisgeneratorfunctionobjectr)rr-r(r)s` @@r_maybe_async_wrapperr2fs_""2&  r     r 5  5 r ) __future__r functoolsrr/rutil.concurrencyrrr rrrrr"r2r r rr7sB*#)l  0<"#*#(!r