Format: application/x-python-code
⬇ Download File (9.2 KB)
   1  o
   2  
   3  7'h�$�	@sddlmZddlZddlZddlmZmZmZzddlZWn
   4  e	e
   5  fy+dZYnwzddlZWne	y=dZYnwddd�ZGd	d
   6  �d
   7  �Z
   8  Gdd�d�ZGd
   9  d�d�ZGdd�d�ZGdd�d�ZGdd�d�ZGdd�d�ZGdd�d�ZGdd�d�ZGdd�d�ZdS)�)�annotationsN�)�ExceptionMapping�PoolTimeout�map_exceptions�return�strcCspzddl}Wntyd}Ynw|��}|dvrtd��|dkr*tdur*td��|dkr6tdur6td��|S)Nr�asyncio)r	�trioz/Running under an unsupported async environment.zBRunning with asyncio requires installation of 'httpcore[asyncio]'.r
  10  z<Running with trio requires installation of 'httpcore[trio]'.)�sniffio�ImportError�current_async_library�RuntimeError�anyior
  11  )r�environment�r�OC:\Users\shubh\Videos\agent\nova\Lib\site-packages\httpcore/_synchronization.pyr
  12  s"���r
  13  c@s@eZdZdZddd�Zddd�Zddd	�Z	
  14  	
  15  	
  16  dddd�Zd
  17  S)�	AsyncLock��
  18      This is a standard lock.
  19  
  20      In the sync case `Lock` provides thread locking.
  21      In the async case `AsyncLock` provides async locking.
  22      r�NonecC�
  23  d|_dS�N���_backend��selfrrr�__init__8�
  24  zAsyncLock.__init__cC�<t�|_|jdkrt��|_dS|jdkrt��|_dSdS�z~
  25          Detect if we're running under 'asyncio' or 'trio' and create
  26          a lock with the correct implementation.
  27          r
  28  r	N)r
  29  rr
  30  �Lock�
  31  _trio_lockr�_anyio_lockrrrr�setup;�
  32  
  33  �zAsyncLock.setupc�sL�|js|��|jdkr|j��IdH|S|jdkr$|j��IdH|S�Nr
  34  r	)rr$r"�acquirer#rrrr�
  35  __aenter__Fs�
  36  
  37  �zAsyncLock.__aenter__N�exc_type�type[BaseException] | None�	exc_value�BaseException | None�	traceback�types.TracebackType | Nonec��6�|jdkr
  38  |j��dS|jdkr|j��dSdSr&)rr"�releaser#�rr)r+r-rrr�	__aexit__Qs�
  39  
  40  �zAsyncLock.__aexit__�rr)rr�NNN�r)r*r+r,r-r.rr)�__name__�
  41  __module__�__qualname__�__doc__rr$r(r2rrrrr0s
  42  
  43  
  44  
  45  �rc@s,eZdZdZddd�Z			ddd
  46  d�ZdS)�AsyncThreadLock��
  47      This is a threading-only lock for no-I/O contexts.
  48  
  49      In the sync case `ThreadLock` provides thread locking.
  50      In the async case `AsyncThreadLock` is a no-op.
  51      rcC�|S�Nrrrrr�	__enter__e�zAsyncThreadLock.__enter__Nr)r*r+r,r-r.rcC�dSr=rr1rrr�__exit__h�zAsyncThreadLock.__exit__)rr:r4r5)r6r7r8r9r>rArrrrr:]s
  52  �r:c@s6eZdZddd�Zddd�Zddd�Zdddd
  53  �Zd	S)�
  54  AsyncEventrrcCrrrrrrrrrrzAsyncEvent.__init__cCrr )r
  55  rr
  56  �Event�_trio_eventr�_anyio_eventrrrrr$ur%zAsyncEvent.setupcCsB|js|��|jdkr|j��dS|jdkr|j��dSdSr&)rr$rE�setrFrrrrrG�s
  57  
  58  �zAsyncEvent.setN�timeout�float | Nonec	�s>�|js|��|jdkrXtjti}|durtd�n|}t|��.t�|��|j�	�IdHWd�n1s9wYWd�dSWd�dS1sQwYdS|jdkr�t
  59  ti}t|��.t�|��|j�	�IdHWd�n1s~wYWd�dSWd�dS1s�wYdSdS)Nr
  60  �infr	)
  61  rr$r
  62  ZTooSlowErrorr�floatrZ
  63  fail_afterrE�wait�TimeoutErrorrrF)rrHZtrio_exc_mapZtimeout_or_infZ
  64  anyio_exc_maprrrrL�s.�
  65  
  66  
  67  ��"�
  68  
  69  ��"��zAsyncEvent.waitr3r=�rHrIrr)r6r7r8rr$rGrLrrrrrCqs
  70  
  71  
  72  
  73  	rCc@s4eZdZddd�Zddd�Zdd	d
  74  �Zddd�Zd
  75  S)�AsyncSemaphore�bound�intrrcCs||_d|_dSr)�_boundr�rrPrrrr�s
  76  zAsyncSemaphore.__init__cCsPt�|_|jdkrtj|j|jd�|_dS|jdkr&tj|j|jd�|_dSdS)z�
  77          Detect if we're running under 'asyncio' or 'trio' and create
  78          a semaphore with the correct implementation.
  79          r
  80  )�
  81  initial_valueZ	max_valuer	N)r
  82  rr
  83  �	SemaphorerR�_trio_semaphorer�_anyio_semaphorerrrrr$�s
  84  �
  85  ��zAsyncSemaphore.setupc�sP�|js|��|jdkr|j��IdHdS|jdkr&|j��IdHdSdSr&)rr$rVr'rWrrrrr'�s�
  86  
  87  �zAsyncSemaphore.acquirec�r/r&)rrVr0rWrrrrr0�s�
  88  
  89  �zAsyncSemaphore.releaseN�rPrQrrr3)r6r7r8rr$r'r0rrrrrO�s
  90  
  91  
  92  
  93  	rOc@s2eZdZddd�Zddd�Z			dddd�ZdS)�AsyncShieldCancellationrrcCsDt�|_|jdkrtjdd�|_dS|jdkr tjdd�|_dSdS)z�
  94          Detect if we're running under 'asyncio' or 'trio' and create
  95          a shielded scope with the correct implementation.
  96          r
  97  T)�shieldr	N)r
  98  rr
  99  ZCancelScope�_trio_shieldr�
 100  _anyio_shieldrrrrr�s
 101  
 102  �z AsyncShieldCancellation.__init__cCs0|jdkr|j��|S|jdkr|j��|Sr&)rr[r>r\rrrrr>�s
 103  
 104  
 105  �
 106  z!AsyncShieldCancellation.__enter__Nr)r*r+r,r-r.cCs@|jdkr|j�|||�dS|jdkr|j�|||�dSdSr&)rr[rAr\r1rrrrA�s
 107  
 108  
 109  �z AsyncShieldCancellation.__exit__r3)rrYr4r5)r6r7r8rr>rArrrrrY�s
 110  
 111  	�rYc@�6eZdZdZddd�Zddd�Z			dddd�ZdS)r!rrrcC�t��|_dSr=��	threadingr!�_lockrrrrr��z
 112  Lock.__init__cC�|j��|Sr=�rar'rrrrr>��
 113  zLock.__enter__Nr)r*r+r,r-r.cC�|j��dSr=�rar0r1rrrrA��z
 114  Lock.__exit__r3)rr!r4r5�r6r7r8r9rr>rArrrrr!��
 115  
 116  �r!c@r])�
 117  ThreadLockr;rrcCr^r=r_rrrrrrbzThreadLock.__init__cCrcr=rdrrrrr>rezThreadLock.__enter__Nr)r*r+r,r-r.cCrfr=rgr1rrrrArhzThreadLock.__exit__r3)rrkr4r5rirrrrrkrjrkc@s,eZdZddd�Zddd�Zd
 118  dd
 119  d�ZdS)rDrrcCr^r=)r`rD�_eventrrrrrrbzEvent.__init__cCrfr=)rlrGrrrrrGrbz	Event.setNrHrIcCs(|td�krd}|jj|d�st��dS)NrJ)rH)rKrlrLr)rrHrrrrLs
 120  �z
 121  Event.waitr3r=rN)r6r7r8rrGrLrrrrrDs
 122  
 123  rDc@s*eZdZddd�Zd
 124  dd�Zd
 125  d	d
 126  �ZdS)rUrPrQrrcCstj|d�|_dS)N)�value)r`rU�
 127  _semaphorerSrrrr'szSemaphore.__init__cCrfr=)rnr'rrrrr'*rbzSemaphore.acquirecCrfr=)rnr0rrrrr0-rbzSemaphore.releaseNrXr3)r6r7r8rr'r0rrrrrU&s
 128  
 129  rUc@s(eZdZddd�Z			dddd
 130  �ZdS)�ShieldCancellationrcCr<r=rrrrrr>5r?zShieldCancellation.__enter__Nr)r*r+r,r-r.rcCr@r=rr1rrrrA8rBzShieldCancellation.__exit__)rror4r5)r6r7r8r>rArrrrro1s
 131  �ro)rr)�
 132  __future__rr`�types�_exceptionsrrrr
 133  r�NotImplementedErrorrr
 134  rr:rCrOrYr!rkrDrUrorrrr�<module>s2��
 135  -)$*