o
    %h                     @   sV   d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z G dd dZdS )	    N)Any)
Connection)create_remote_object)PipeTransport)
Playwrightc                   @   sD   e Zd ZdddZdefddZdefddZd	eddfd
dZdS )PlaywrightContextManagerreturnNc                 C   s   |  d| _ d S )NF)_exit_was_calledself r   Y/var/www/html/myenv/lib/python3.10/site-packages/playwright/async_api/_context_manager.py__init__   s   
z!PlaywrightContextManager.__init__c                    s   t  }td tt||| _|| j  | jj}t j	| jj
j|ht jdI d H \}}| s5|  ttt| }| j|_|S )N)return_when)asyncioget_running_loopr   r   r   _connectioncreate_taskrunplaywright_futurewait
_transporton_error_futureFIRST_COMPLETEDdonecancelAsyncPlaywrightnextiterresult	__aexit__stop)r   loopr   r   _
playwrightr   r   r   
__aenter__   s&   z#PlaywrightContextManager.__aenter__c                    s   |   I d H S )N)r%   r
   r   r   r   start2   s   zPlaywrightContextManager.startargsc                    s&   | j rd S d| _ | j I d H  d S )NT)r	   r   
stop_async)r   r'   r   r   r   r    5   s
   z"PlaywrightContextManager.__aexit__)r   N)	__name__
__module____qualname__r   r   r%   r&   r   r    r   r   r   r   r      s
    
r   )r   typingr   playwright._impl._connectionr    playwright._impl._object_factoryr   playwright._impl._transportr   playwright.async_api._generatedr   r   r   r   r   r   r   <module>   s   