o
    h%                     @  s  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jd
kr]d dlmZmZ nd dlmZmZ ejdkrqd dlm Z  nd dlm Z  erd 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  d ed!ZCdS )"    )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                   @  s   e Zd Zeedd
dZeedddZeedddZeedddZeedddZ	edddZ
edddZeedddZeeejdd dd%d&Zeedd'd(Zeedd*d+Zeedd-d.Zeedd1d2Zeed3dd4dd:d;Zeedd>d?Zee		3dddDdEZeeddFdGZeeddIdJZeeddKdLZeeddNdOZeeddXdYZeedd\d]Zee	3dddddeZeeddidjZeeddndoZeeddpdqZ eeddwdxZ!ee"dd|d}Z#ee"ddd}Z#eeddd}Z#eeddddddddZ$ee	ddddZ%eedddZ&eedddZ'eedddZ(eedddZ)eedddZ*eedddZ+eedddZ,eedddZ-d3S )AsyncBackendfunc1Callable[[Unpack[PosArgsT]], Awaitable[T_Retval]]argstuple[Unpack[PosArgsT]]kwargsdict[str, Any]optionsreturnr0   c                 C     dS )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 )clsr4   r6   r8   r:   r=   r=   h/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/anyio/abc/_eventloop.pyrun9       zAsyncBackend.runobjectc                 C  r<   )z

        :return:
        Nr=   r>   r=   r=   r?   current_tokenO   rA   zAsyncBackend.current_tokenfloatc                 C  r<   )zz
        Return the current value of the event loop's internal clock.

        :return: the clock value (seconds)
        Nr=   rC   r=   r=   r?   current_timeW   rA   zAsyncBackend.current_timetype[BaseException]c                 C  r<   )zFReturn the exception class that is raised in a task if it's cancelled.Nr=   rC   r=   r=   r?   cancelled_exception_class`   rA   z&AsyncBackend.cancelled_exception_classNonec                      dS )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`.
        Nr=   rC   r=   r=   r?   
checkpointe       zAsyncBackend.checkpointc                   s(   |   tj kr|  I dH  dS dS )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infrK   rC   r=   r=   r?   checkpoint_if_cancelledo   s   	z$AsyncBackend.checkpoint_if_cancelledc                   sD   | j dd | dI dH  W d   dS 1 sw   Y  dS )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sleeprC   r=   r=   r?   cancel_shielded_checkpoint{   s   	"z'AsyncBackend.cancel_shielded_checkpointdelayc                   rJ   )zt
        Pause the current task for the specified duration.

        :param delay: the duration, in seconds
        Nr=   )r>   rU   r=   r=   r?   rS      rL   zAsyncBackend.sleepF)deadlinerQ   rV   rQ   boolr!   c                C     d S Nr=   )r>   rV   rQ   r=   r=   r?   rR         z AsyncBackend.create_cancel_scopec                 C  r<   )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
        Nr=   rC   r=   r=   r?   rM      rA   z'AsyncBackend.current_effective_deadliner.   c                 C  rX   rY   r=   rC   r=   r=   r?   create_task_group      zAsyncBackend.create_task_groupr   c                 C  rX   rY   r=   rC   r=   r=   r?   create_event   r\   zAsyncBackend.create_eventfast_acquirer   c                C  rX   rY   r=   )r>   r^   r=   r=   r?   create_lock   r\   zAsyncBackend.create_lockN)	max_valuer^   initial_valueintr`   
int | Noner    c                C  rX   rY   r=   )r>   ra   r`   r^   r=   r=   r?   create_semaphore   s   	zAsyncBackend.create_semaphoretotal_tokensr   c                 C  rX   rY   r=   )r>   re   r=   r=   r?   create_capacity_limiter   r\   z$AsyncBackend.create_capacity_limiter&Callable[[Unpack[PosArgsT]], T_Retval]abandon_on_cancellimiterCapacityLimiter | Nonec                      d S rY   r=   )r>   r4   r6   rh   ri   r=   r=   r?   run_sync_in_worker_thread      	z&AsyncBackend.run_sync_in_worker_threadc                 C  rX   rY   r=   rC   r=   r=   r?   check_cancelled   r\   zAsyncBackend.check_cancelledtokenc                 C  rX   rY   r=   r>   r4   r6   ro   r=   r=   r?   run_async_from_thread      z"AsyncBackend.run_async_from_threadc                 C  rX   rY   r=   rp   r=   r=   r?   run_sync_from_thread   rr   z!AsyncBackend.run_sync_from_threadr#   c                 C  rX   rY   r=   rC   r=   r=   r?   create_blocking_portal   r\   z#AsyncBackend.create_blocking_portalcommand)StrOrBytesPath | Sequence[StrOrBytesPath]stdinint | IO[Any] | Nonestdoutstderrr   r-   c                  rk   rY   r=   )r>   ru   rw   ry   rz   r8   r=   r=   r?   open_process   s   zAsyncBackend.open_processworkersset[Process]c                 C  rX   rY   r=   )r>   r|   r=   r=   r?   #setup_process_pool_exit_at_shutdown   r\   z0AsyncBackend.setup_process_pool_exit_at_shutdownhoststrportlocal_addressIPSockAddrType | Noner)   c                   rk   rY   r=   )r>   r   r   r   r=   r=   r?   connect_tcp      zAsyncBackend.connect_tcppathstr | bytesr,   c                   rk   rY   r=   )r>   r   r=   r=   r?   connect_unix     zAsyncBackend.connect_unixsockr   r(   c                 C  rX   rY   r=   r>   r   r=   r=   r?   create_tcp_listener  r\   z AsyncBackend.create_tcp_listenerc                 C  rX   rY   r=   r   r=   r=   r?   create_unix_listener  r\   z!AsyncBackend.create_unix_listenerfamilyr   remote_address
reuse_portUDPSocket | ConnectedUDPSocketc                   rk   rY   r=   )r>   r   r   r   r   r=   r=   r?   create_udp_socket  rm   zAsyncBackend.create_udp_socket
raw_socketremote_pathr+   c                   rk   rY   r=   r>   r   r   r=   r=   r?   create_unix_datagram_socket      z(AsyncBackend.create_unix_datagram_socketr&   c                   rk   rY   r=   r   r=   r=   r?   r   &  r   str | bytes | None0UNIXDatagramSocket | ConnectedUNIXDatagramSocketc                   rk   rY   r=   r   r=   r=   r?   r   ,  r   r   )r   typeprotoflagsbytes | str | Nonestr | int | Noneint | AddressFamilyr   int | SocketKindr   r   uSequence[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int] | tuple[int, bytes]]]c                  rk   rY   r=   )r>   r   r   r   r   r   r   r=   r=   r?   getaddrinfo3  s   zAsyncBackend.getaddrinfosockaddrr'   tuple[str, str]c                   rk   rY   r=   )r>   r   r   r=   r=   r?   getnameinfoI  r   zAsyncBackend.getnameinfoobjHasFileno | intc                   rk   rY   r=   r>   r   r=   r=   r?   wait_readableP  r   zAsyncBackend.wait_readablec                   rk   rY   r=   r   r=   r=   r?   wait_writableU  r   zAsyncBackend.wait_writablec                 C  rX   rY   r=   rC   r=   r=   r?   current_default_thread_limiterZ  r\   z+AsyncBackend.current_default_thread_limitersignalsr   .AbstractContextManager[AsyncIterator[Signals]]c                 G  rX   rY   r=   )r>   r   r=   r=   r?   open_signal_receiver_  rZ   z!AsyncBackend.open_signal_receiverr"   c                 C  rX   rY   r=   rC   r=   r=   r?   get_current_taskf  r\   zAsyncBackend.get_current_taskSequence[TaskInfo]c                 C  rX   rY   r=   rC   r=   r=   r?   get_running_tasksk  r\   zAsyncBackend.get_running_tasksc                   rk   rY   r=   rC   r=   r=   r?   wait_all_tasks_blockedp  r   z#AsyncBackend.wait_all_tasks_blockedr/   c                 C  rX   rY   r=   )r>   r:   r=   r=   r?   create_test_runneru  r\   zAsyncBackend.create_test_runner)
r4   r5   r6   r7   r8   r9   r:   r9   r;   r0   )r;   rB   )r;   rE   )r;   rG   )r;   rI   )rU   rE   r;   rI   )rV   rE   rQ   rW   r;   r!   )r;   r.   )r;   r   )r^   rW   r;   r   )ra   rb   r`   rc   r^   rW   r;   r    )re   rE   r;   r   )FN)
r4   rg   r6   r7   rh   rW   ri   rj   r;   r0   )r4   r5   r6   r7   ro   rB   r;   r0   )r4   rg   r6   r7   ro   rB   r;   r0   )r;   r#   )ru   rv   rw   rx   ry   rx   rz   rx   r8   r   r;   r-   )r|   r}   r;   rI   rY   )r   r   r   rb   r   r   r;   r)   )r   r   r;   r,   )r   r   r;   r(   )
r   r   r   r   r   r   r   rW   r;   r   )r   r   r   rI   r;   r+   )r   r   r   r   r;   r&   )r   r   r   r   r;   r   )r   r   r   r   r   r   r   r   r   rb   r   rb   r;   r   )r   )r   r'   r   rb   r;   r   )r   r   r;   rI   )r;   r   )r   r   r;   r   )r;   r"   )r;   r   )r:   r9   r;   r/   ).__name__
__module____qualname__classmethodr   r@   rD   rF   rH   rK   rP   rT   rS   rN   rO   rR   rM   r[   r]   r_   rd   rf   rl   rn   rq   rs   rt   r{   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r=   r=   r=   r?   r3   8   s   			r3   )	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.   _testingr/   r0   r1   r   bytesr2   __annotations__r3   r=   r=   r=   r?   <module>   s<     
	
(
