o
    ,wii                     @   sP   d Z ddlZdddZdd Zdd Z									dd
dZdd Zdd ZdS )z2
Utilities used in patching.

Internal use only.

    Nc                 C   s   ddl m} || _||  d S )Nr   )notify_and_call_entry_points)gevent.eventsr   	_warnings)eventr   r    r   P/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/gevent/monkey/_util.py_notify_patch   s   r   c                    s$   ddl m} |  fdd}|S )Nr   )wrapsc                     s2   ddl m} z | i |W S  |y   Y dS w )Nr   )
DoNotPatchF)r   r
   )argskwargsr
   funcr   r   ignores   s   z$_ignores_DoNotPatch.<locals>.ignores)	functoolsr	   )r   r	   r   r   r   r   _ignores_DoNotPatch   s   r   c                 C   s0   t td|  | }t |d| }t|}|||fS )z
    Test that the source and target modules for *name* are
    available and return them.

    :raise ImportError: If the source or target cannot be imported.
    :return: The tuple ``(gevent_module, target_module, target_module_name)``
    zgevent.
__target__)getattr
__import__)namegevent_moduletarget_module_nametarget_moduler   r   r   _check_availability    s   

r   Tc              
   C   s   ddl m} t| \}}	}
||	|||||||d t|dd}ddlm} |D ]'}tj|}|d urN||	urN|	|d  |||||dddd ||
 ||< q'||	fS )	N   )patch_module)itemsr   _patch_kwargs_notify_will_subscribers_notify_did_subscribers_call_hooks__alternate_targets__r   )savedF)r   r   r   r   r    )
apir   r   r   _stater"   sysmodulesgetpop)r   r   r   r   r   r   r    r   r   r   r   alternate_namesr"   alternate_namealternate_moduler   r   r   _patch_module1   s.   r,   c                 C   s$   |d u rt | g d S ||  d S N)_process_warningsappend)messager   r   r   r   _queue_warning[   s   r1   c                 C   s2   dd l }ddlm} | D ]
}|j||dd qd S )Nr   r   )MonkeyPatchWarning   )
stacklevel)warnings_errorsr2   warn)r   r5   r2   warningr   r   r   r.   e   s
   r.   r-   )NNNTTT)__doc__r%   r   r   r   r,   r1   r.   r   r   r   r   <module>   s   

*
