관리-도구
편집 파일: asyncio.cpython-38.pyc
U -?�f� � @ sv d dl mZ d dlmZ d dlZddlmZ ddlmZ dZ e� Z d d � Zdd� Zd d� Z dd� Zdd� Zdd� ZdS )� )�annotations)�wrapsN� )�config� )� _AsyncUtilTc C s t �� dS )zcalled when the test finishesN)�_async_util�close� r r �J/opt/hc_python/lib64/python3.8/site-packages/sqlalchemy/testing/asyncio.py� _shutdown# s r c O s t j| f|�|�S �N)r �run��fn�args�kwargsr r r �_run_coroutine_function( s r c O s t s| ||�S tj| f|�|�S )a Run 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_greenletr r r r � _assume_async, s r c O s4 t s| ||�S tjr&tj| f|�|�S | ||�S dS )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)r r Z any_asyncr r r r r r �_maybe_async_provisioning= s r c O s: t s| ||�S tjj}|r,tj| f|�|�S | ||�S dS )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)r r �_current�is_asyncr r )r r r r r r r �_maybe_asyncR s r c sN t ���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. c s( z t | �W S tk r" � Y S X d S r )�next� StopIteration)�gen)�_stopr r � call_nextq s z'_maybe_async_wrapper.<locals>.call_nextc ? s* �| |�}t �|�}|� krq&|V q d S r �r )r r r �value�r r r r r �wrap_fixturex s z*_maybe_async_wrapper.<locals>.wrap_fixturec s t � f| �|�S r r )r r )r r r r# � s )�inspect�isgeneratorfunction�objectr )r r# r r"