U ÃÏ aÙã@shddlmZddlZddlmZddlmZddlmZdZd d „Z d d „Z d d„Z dd„Z dd„Z dS)é)ÚwrapsNé)Úconfigé)Ú_util_async_run©Ú"_util_async_run_coroutine_functionTcOst|f|ž|ŽS©Nr©ÚfnÚargsÚkwargs©rú[C:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-nyjtotrf\sqlalchemy\testing\asyncio.pyÚ_run_coroutine_function srcOsts|||ŽSt|f|ž|Ž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_ASYNCIOrr rrrÚ _assume_async$s  rcOs2ts|||ŽStjr$t|f|ž|ŽS|||ŽSdS)a¸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 driver, it will run in asyncio and not fail. Note that for blocking IO database drivers, this means they block the event loop. N)rrZ any_asyncrr rrrÚ_maybe_async_provisioning5s  rcOs8ts|||ŽStjj}|r*t|f|ž|ŽS|||ŽSdS)zÇRun 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. N)rrÚ_currentÚis_asyncr)r r r rrrrÚ _maybe_asyncKs  rcsNt ˆ¡r6tƒ‰‡fdd„‰tˆƒ‡‡‡fdd„ƒ}ntˆƒ‡fdd„ƒ}|S)z×Apply 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. cs(z t|ƒWStk r"ˆYSXdSr )ÚnextÚ StopIteration)Úgen)Ú_stoprrÚ call_nextks z'_maybe_async_wrapper..call_nextc?s*ˆ||Ž}tˆ|ƒ}|ˆkrq&|Vq dSr ©r)r r rÚvalue©rrr rrÚ wrap_fixturers   z*_maybe_async_wrapper..wrap_fixturecstˆf|ž|ŽSr r)r r )r rrr}s)ÚinspectÚisgeneratorfunctionÚobjectr)r rrrrÚ_maybe_async_wrapper`s   r#)Ú functoolsrr ÚrZutil.concurrencyrrrrrrrr#rrrrÚs