
    Ih%                       U d dl mZ d dlZd dlZd dlmZmZ d dlmZm	Z	m
Z
mZ d dlmZ d dlmZ d dlmZ d dlmZmZmZ d d	lmZmZmZmZmZmZ ej8                  d
k\  r	d dlmZmZ nd dlmZmZ ej8                  dk\  rd dlm Z  nd dlm Z  erJd dl!m"Z" ddl#m$Z$m%Z%m&Z&m'Z' ddl(m)Z) ddl*m+Z+ ddl,m-Z- ddl.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6 ddl7m8Z8 ddl9m:Z: ddl;m<Z<  ed      Z= ed      Z>ee?e@ddf   ZAdeBd<    G d d e!      ZCy)"    )annotationsN)ABCMetaabstractmethod)AsyncIterator	AwaitableCallableSequence)AbstractContextManager)PathLike)Signals)AddressFamily
SocketKindsocket)IOTYPE_CHECKINGAnyTypeVarUnionoverload)      )TypeVarTupleUnpack)r   
   )	TypeAlias)	HasFileno   )CapacityLimiterEventLock	Semaphore)CancelScope)TaskInfo)BlockingPortal   )ConnectedUDPSocketConnectedUNIXDatagramSocketIPSockAddrTypeSocketListenerSocketStream	UDPSocketUNIXDatagramSocketUNIXSocketStream)Process)	TaskGroup)
TestRunnerT_RetvalPosArgsTzPathLike[str]zPathLike[bytes]r   StrOrBytesPathc                  ~   e Zd Zee	 	 	 	 	 	 	 	 	 	 d/d              Zeed0d              Zeed1d              Zeed2d              Zeed3d              Z	ed3d       Z
ed3d       Zeed4d              Zeeej                  d	d
	 	 	 	 	 d5d              Zeed1d              Zeed6d              Zeed7d              Zeed8d              Zeedd	d	 	 	 	 	 	 	 d9d              Zeed:d              Zee	 	 d;	 	 	 	 	 	 	 	 	 d<d              Zeed3d              Zee	 	 	 	 	 	 	 	 d=d              Zee	 	 	 	 	 	 	 	 d>d              Zeed?d              Zee	 	 	 	 	 	 	 	 	 	 	 	 d@d              ZeedAd              Zee	 dB	 	 	 	 	 	 	 dCd              ZeedDd              ZeedEd              ZeedEd              Z ee	 	 	 	 	 	 	 	 	 	 dFd              Z!ee"	 	 	 	 	 	 dGd               Z#ee"	 	 	 	 	 	 dHd!              Z#ee	 	 	 	 	 	 dId"              Z#eed#d#d#d#d$	 	 	 	 	 	 	 	 	 	 	 	 	 dJd%              Z$ee	 dK	 	 	 	 	 dLd&              Z%eedMd'              Z&eedMd(              Z'eedNd)              Z(ee	 	 	 	 dOd*              Z)eedPd+              Z*eedQd,              Z+eed3d-              Z,eedRd.              Z-y)SAsyncBackendc                     y)a  
        Run the given coroutine function in an asynchronous event loop.

        The current thread must not be already running an event loop.

        :param func: a coroutine function
        :param args: positional arguments to ``func``
        :param kwargs: positional arguments to ``func``
        :param options: keyword arguments to call the backend ``run()`` implementation
            with
        :return: the return value of the coroutine function
        N )clsfuncargskwargsoptionss        H/var/www/test/myenv/lib/python3.12/site-packages/anyio/abc/_eventloop.pyrunzAsyncBackend.run9           c                     y)z

        :return:
        Nr7   r8   s    r=   current_tokenzAsyncBackend.current_tokenO   r?   r@   c                     y)zz
        Return the current value of the event loop's internal clock.

        :return: the clock value (seconds)
        Nr7   rB   s    r=   current_timezAsyncBackend.current_timeW   r?   r@   c                     y)zFReturn the exception class that is raised in a task if it's cancelled.Nr7   rB   s    r=   cancelled_exception_classz&AsyncBackend.cancelled_exception_class`   r?   r@   c                   K   yw)z
        Check if the task has been cancelled, and allow rescheduling of other tasks.

        This is effectively the same as running :meth:`checkpoint_if_cancelled` and then
        :meth:`cancel_shielded_checkpoint`.
        Nr7   rB   s    r=   
checkpointzAsyncBackend.checkpointe           c                   K   | j                         t        j                   k(  r| j                          d{    yy7 w)z
        Check if the current task group has been cancelled.

        This will check if the task has been cancelled, but will not allow other tasks
        to be scheduled if not.

        N)current_effective_deadlinemathinfrI   rB   s    r=   checkpoint_if_cancelledz$AsyncBackend.checkpoint_if_cancelledo   s7      ))+y8..""" 9"s   6A?Ac                   K   | j                  d      5  | j                  d       d{    ddd       y7 # 1 sw Y   yxY ww)z
        Allow the rescheduling of other tasks.

        This will give other tasks the opportunity to run, but without checking if the
        current task group has been cancelled, unlike with :meth:`checkpoint`.

        T)shieldr   N)create_cancel_scopesleeprB   s    r=   cancel_shielded_checkpointz'AsyncBackend.cancel_shielded_checkpoint{   sG      $$D$1 	))A,	 		 	s$   A:8:	A:AAc                   K   yw)zt
        Pause the current task for the specified duration.

        :param delay: the duration, in seconds
        Nr7   )r8   delays     r=   rT   zAsyncBackend.sleep   rJ   rK   F)deadlinerR   c                    y Nr7   )r8   rX   rR   s      r=   rS   z AsyncBackend.create_cancel_scope       
 	r@   c                     y)aQ  
        Return the nearest deadline among all the cancel scopes effective for the
        current task.

        :return:
            - a clock value from the event loop's internal clock
            - ``inf`` if there is no deadline in effect
            - ``-inf`` if the current scope has been cancelled
        :rtype: float
        Nr7   rB   s    r=   rM   z'AsyncBackend.current_effective_deadline   r?   r@   c                     y rZ   r7   rB   s    r=   create_task_groupzAsyncBackend.create_task_group        	r@   c                     y rZ   r7   rB   s    r=   create_eventzAsyncBackend.create_event   r_   r@   c                    y rZ   r7   )r8   fast_acquires     r=   create_lockzAsyncBackend.create_lock   r_   r@   N)	max_valuerc   c                    y rZ   r7   )r8   initial_valuere   rc   s       r=   create_semaphorezAsyncBackend.create_semaphore   s     	r@   c                     y rZ   r7   )r8   total_tokenss     r=   create_capacity_limiterz$AsyncBackend.create_capacity_limiter   r_   r@   c                   K   y wrZ   r7   )r8   r9   r:   abandon_on_cancellimiters        r=   run_sync_in_worker_threadz&AsyncBackend.run_sync_in_worker_thread         	rK   c                     y rZ   r7   rB   s    r=   check_cancelledzAsyncBackend.check_cancelled   r_   r@   c                     y rZ   r7   r8   r9   r:   tokens       r=   run_async_from_threadz"AsyncBackend.run_async_from_thread        	r@   c                     y rZ   r7   rt   s       r=   run_sync_from_threadz!AsyncBackend.run_sync_from_thread   rw   r@   c                     y rZ   r7   rB   s    r=   create_blocking_portalz#AsyncBackend.create_blocking_portal   r_   r@   c                  K   y wrZ   r7   )r8   commandstdinstdoutstderrr;   s         r=   open_processzAsyncBackend.open_process   s      	rK   c                     y rZ   r7   )r8   workerss     r=   #setup_process_pool_exit_at_shutdownz0AsyncBackend.setup_process_pool_exit_at_shutdown   r_   r@   c                   K   y wrZ   r7   )r8   hostportlocal_addresss       r=   connect_tcpzAsyncBackend.connect_tcp        
 	rK   c                   K   y wrZ   r7   )r8   paths     r=   connect_unixzAsyncBackend.connect_unix        	rK   c                     y rZ   r7   r8   socks     r=   create_tcp_listenerz AsyncBackend.create_tcp_listener  r_   r@   c                     y rZ   r7   r   s     r=   create_unix_listenerz!AsyncBackend.create_unix_listener  r_   r@   c                   K   y wrZ   r7   )r8   familyr   remote_address
reuse_ports        r=   create_udp_socketzAsyncBackend.create_udp_socket  rp   rK   c                   K   y wrZ   r7   r8   
raw_socketremote_paths      r=   create_unix_datagram_socketz(AsyncBackend.create_unix_datagram_socket   s      !rK   c                   K   y wrZ   r7   r   s      r=   r   z(AsyncBackend.create_unix_datagram_socket&  s      '*rK   c                   K   y wrZ   r7   r   s      r=   r   z(AsyncBackend.create_unix_datagram_socket,  r   rK   r   )r   typeprotoflagsc                  K   y wrZ   r7   )r8   r   r   r   r   r   r   s          r=   getaddrinfozAsyncBackend.getaddrinfo3  s     ( 	rK   c                   K   y wrZ   r7   )r8   sockaddrr   s      r=   getnameinfozAsyncBackend.getnameinfoI  r   rK   c                   K   y wrZ   r7   r8   objs     r=   wait_readablezAsyncBackend.wait_readableP  r   rK   c                   K   y wrZ   r7   r   s     r=   wait_writablezAsyncBackend.wait_writableU  r   rK   c                     y rZ   r7   rB   s    r=   current_default_thread_limiterz+AsyncBackend.current_default_thread_limiterZ  r_   r@   c                     y rZ   r7   )r8   signalss     r=   open_signal_receiverz!AsyncBackend.open_signal_receiver_  r[   r@   c                     y rZ   r7   rB   s    r=   get_current_taskzAsyncBackend.get_current_taskf  r_   r@   c                     y rZ   r7   rB   s    r=   get_running_taskszAsyncBackend.get_running_tasksk  r_   r@   c                   K   y wrZ   r7   rB   s    r=   wait_all_tasks_blockedz#AsyncBackend.wait_all_tasks_blockedp  r   rK   c                     y rZ   r7   )r8   r<   s     r=   create_test_runnerzAsyncBackend.create_test_runneru  r_   r@   )
r9   1Callable[[Unpack[PosArgsT]], Awaitable[T_Retval]]r:   tuple[Unpack[PosArgsT]]r;   dict[str, Any]r<   r   returnr1   )r   object)r   float)r   ztype[BaseException])r   None)rW   r   r   r   )rX   r   rR   boolr   r"   )r   r/   )r   r   )rc   r   r   r    )rg   intre   z
int | Nonerc   r   r   r!   )rj   r   r   r   )FN)
r9   &Callable[[Unpack[PosArgsT]], T_Retval]r:   r   rm   r   rn   zCapacityLimiter | Noner   r1   )r9   r   r:   r   ru   r   r   r1   )r9   r   r:   r   ru   r   r   r1   )r   r$   )r}   z)StrOrBytesPath | Sequence[StrOrBytesPath]r~   int | IO[Any] | Noner   r   r   r   r;   r   r   r.   )r   zset[Process]r   r   rZ   )r   strr   r   r   IPSockAddrType | Noner   r*   )r   str | bytesr   r-   )r   r   r   r)   )
r   r   r   r   r   r   r   r   r   zUDPSocket | ConnectedUDPSocket)r   r   r   r   r   r,   )r   r   r   r   r   r'   )r   r   r   zstr | bytes | Noner   z0UNIXDatagramSocket | ConnectedUNIXDatagramSocket)r   zbytes | str | Noner   zstr | int | Noner   zint | AddressFamilyr   zint | SocketKindr   r   r   r   r   zuSequence[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes]]])r   )r   r(   r   r   r   ztuple[str, str])r   zHasFileno | intr   r   )r   r   )r   r   r   z.AbstractContextManager[AsyncIterator[Signals]])r   r#   )r   zSequence[TaskInfo])r<   r   r   r0   ).__name__
__module____qualname__classmethodr   r>   rC   rE   rG   rI   rP   rU   rT   rN   rO   rS   rM   r^   ra   rd   rh   rk   ro   rr   rv   ry   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r7   r@   r=   r5   r5   8   s   ? & 	
   
  (       U  U    	# 	# 	 	    "&((548	  
 
  
          
 !%" 	
  
      
 #(*.4 &  	
 ( 
      ? & 	
 
   4 & 	
 
      	:	 $		
 %	 %	 	 
	  	    JN!2G	  
           - .	
  
(   !!.2!	!  ! **.9*	$*  * .@	9  
  '(!"  
 $   
  ( 45%.1	  
          	7  
            r@   r5   )	metaclass)D
__future__r   rN   sysabcr   r   collections.abcr   r   r   r	   
contextlibr
   osr   signalr   r   r   r   typingr   r   r   r   r   r   version_infor   r   typing_extensionsr   	_typeshedr   _core._synchronizationr   r   r    r!   _core._tasksr"   _core._testingr#   from_threadr$   _socketsr&   r'   r(   r)   r*   r+   r,   r-   _subprocessesr.   _tasksr/   _testingr0   r1   r2   r   bytesr3   __annotations__r5   r7   r@   r=   <module>r      s    "  
 ' H H -   4 4  w++6w +#PP*),	 	 	 '!$:
#!#uo?P"PQ	 Q@W @r@   