U kf@svddlmZddlmZddlZddlmZddlmZdZ eZ d d Z d d Z d dZ ddZddZddZdS)) annotations)wrapsN)config) _AsyncUtilTcCs tdS)zcalled when the test finishesN) _async_utilcloser r J/opt/hc_python/lib64/python3.8/site-packages/sqlalchemy/testing/asyncio.py _shutdown#sr cOstj|f||SN)rrunfnargskwargsr r r _run_coroutine_function(srcOs ts|||Stj|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_ASYNCIOrrun_in_greenletrr r r _assume_async,s  rcOs4ts|||Stjr&tj|f||S|||SdS)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. N)rrZ any_asyncrrrr r r _maybe_async_provisioning=s  rcOs:ts|||Stjj}|r,tj|f||S|||SdS)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. N)rr_currentis_asyncrr)rrrrr r r _maybe_asyncRs  rcsNtr6tfddtfdd}ntfdd}|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. cs(z t|WStk r"YSXdSr )next StopIteration)gen)_stopr r call_nextqs z'_maybe_async_wrapper..call_nextc?s*||}t|}|krq&|Vq dSr r)rrrvaluerrrr r wrap_fixturexs   z*_maybe_async_wrapper..wrap_fixturecstf||Sr r )rr)rr r r#s)inspectisgeneratorfunctionobjectr)rr#r r"r _maybe_async_wrapperfs   r') __future__r functoolsrr$rZutil.concurrencyrrrr rrrrr'r r r r s