o
    0׾g                     @   s   d Z ddlmZ ddlZddlmZ ddlmZ ddlmZ ddl	Z
efZdZe
jZi Zdad	d
 Zdd Zdd Zdd Zg ZeZeZddlmZ ee
e edZdS )z5gevent friendly implementations of builtin functions.    )absolute_importN)RLock)imp_acquire_lock)imp_release_lockbuiltinsTc                    sT   d }zt    }W n	 ty   Y nw |d u r(t } fdd}t||t  < |S )Nc                    s   t  d  d S )N)_g_import_lockspop)_name Y/var/www/html/backend_erp/backend_erp_env/lib/python3.10/site-packages/gevent/builtins.pycb6   s   z__module_lock.<locals>.cb)r   KeyErrorr   weakrefref)r   lockr   r   r
   r   __module_lock&   s   r   c                  O   s   | rt t| d ts| dd } tst| i |S t| d }t  z|  zt| i |}W |  n|  w W t	  |S t	  w )a  
    __import__(name, globals=None, locals=None, fromlist=(), level=0) -> object

    Normally python protects imports against concurrency by doing some locking
    at the C level (at least, it does that in CPython).  This function just
    wraps the normal __import__ functionality in a recursive lock, ensuring that
    we're protected against greenlet import concurrency as well.
    r      N)

issubclasstype_allowed_module_name_types__lock_imports_importr   r   acquirereleaser   )argskwargsmodule_lockresultr   r   r   
__import__=   s   	r    c                   C   s   da dS )a  
    Internal function, called when gevent needs to perform imports
    lazily, but does not know the state of the system. It may be impossible
    to take the import lock because there are no other running greenlets, for
    example. This causes a monkey-patched __import__ to avoid taking any locks.
    until the corresponding call to lock_imports. This should only be done for limited
    amounts of time and when the set of imports is statically known to be "safe".
    FNr   r   r   r   r   _unlock_imports]   s   r"   c                   C   s   da d S )NTr!   r   r   r   r   _lock_importsm   s   r#   )copy_globals)names_to_ignore)__doc__
__future__r   r   gevent.lockr   gevent._compatr   r   r   __gbuiltins__strr   
__target__r    r   r   r   r   r"   r#   __implements____all__gevent._utilr$   globals__imports__r   r   r   r   <module>   s.    
