o
    ii)                     @  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-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4 ddl5m6Z6 ddl7m8Z8 ddl9m:Z: edZ;edZ<ee=e>ddf Z?de@d< G dd ded ZAd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)FileDescriptorLike   )CapacityLimiterEventLock	Semaphore)CancelScope)TaskInfo   )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ddUdVZeeddYdZZee	3dddadbZeeddfdgZeeddkdlZeeddmdnZeeddtduZ ee!ddydzZ"ee!dd|dzZ"eedddz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,eedddZ-eedddZ.eedddZ/eedddZ0eedddZ1eedddZ2eedddZ3eedddZ4d3S )AsyncBackendfunc1Callable[[Unpack[PosArgsT]], Awaitable[T_Retval]]argstuple[Unpack[PosArgsT]]kwargsdict[str, Any]optionsreturnr/   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 )clsr3   r5   r7   r9   r<   r<   T/home/air/goalskill_t/back/venv/lib/python3.10/site-packages/anyio/abc/_eventloop.pyrun8       zAsyncBackend.runobjectc                 C  r;   )z
        Return an object that allows other threads to run code inside the event loop.

        :return: a token object, specific to the event loop running in the current
            thread
        Nr<   r=   r<   r<   r>   current_tokenN   r@   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<   rB   r<   r<   r>   current_timeX   r@   zAsyncBackend.current_timetype[BaseException]c                 C  r;   )zFReturn the exception class that is raised in a task if it's cancelled.Nr<   rB   r<   r<   r>   cancelled_exception_classa   r@   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<   rB   r<   r<   r>   
checkpointf       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infrJ   rB   r<   r<   r>   checkpoint_if_cancelledp   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sleeprB   r<   r<   r>   cancel_shielded_checkpoint|   s   	"z'AsyncBackend.cancel_shielded_checkpointdelayc                   rI   )zt
        Pause the current task for the specified duration.

        :param delay: the duration, in seconds
        Nr<   )r=   rT   r<   r<   r>   rR      rK   zAsyncBackend.sleepF)deadlinerP   rU   rP   boolr!   c                C     d S Nr<   )r=   rU   rP   r<   r<   r>   rQ         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<   rB   r<   r<   r>   rL      r@   z'AsyncBackend.current_effective_deadliner-   c                 C  rW   rX   r<   rB   r<   r<   r>   create_task_group      zAsyncBackend.create_task_groupr   c                 C  rW   rX   r<   rB   r<   r<   r>   create_event   r[   zAsyncBackend.create_eventfast_acquirer   c                C  rW   rX   r<   )r=   r]   r<   r<   r>   create_lock   r[   zAsyncBackend.create_lockN)	max_valuer]   initial_valueintr_   
int | Noner    c                C  rW   rX   r<   )r=   r`   r_   r]   r<   r<   r>   create_semaphore   s   	zAsyncBackend.create_semaphoretotal_tokensr   c                 C  rW   rX   r<   )r=   rd   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 rX   r<   )r=   r3   r5   rg   rh   r<   r<   r>   run_sync_in_worker_thread      	z&AsyncBackend.run_sync_in_worker_threadc                 C  rW   rX   r<   rB   r<   r<   r>   check_cancelled   r[   zAsyncBackend.check_cancelledtokenc                 C  rW   rX   r<   r=   r3   r5   rn   r<   r<   r>   run_async_from_thread      z"AsyncBackend.run_async_from_threadc                 C  rW   rX   r<   ro   r<   r<   r>   run_sync_from_thread   rq   z!AsyncBackend.run_sync_from_threadcommand)StrOrBytesPath | Sequence[StrOrBytesPath]stdinint | IO[Any] | Nonestdoutstderrr   r,   c                  rj   rX   r<   )r=   rs   ru   rw   rx   r7   r<   r<   r>   open_process   s   zAsyncBackend.open_processworkersset[Process]c                 C  rW   rX   r<   )r=   rz   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                   rj   rX   r<   )r=   r}   r   r   r<   r<   r>   connect_tcp      zAsyncBackend.connect_tcppathstr | bytesr+   c                   rj   rX   r<   )r=   r   r<   r<   r>   connect_unix     zAsyncBackend.connect_unixsockr   r'   c                 C  rW   rX   r<   r=   r   r<   r<   r>   create_tcp_listener  r[   z AsyncBackend.create_tcp_listenerc                 C  rW   rX   r<   r   r<   r<   r>   create_unix_listener  r[   z!AsyncBackend.create_unix_listenerfamilyr   remote_address
reuse_portUDPSocket | ConnectedUDPSocketc                   rj   rX   r<   )r=   r   r   r   r   r<   r<   r>   create_udp_socket  rl   zAsyncBackend.create_udp_socket
raw_socketremote_pathr*   c                   rj   rX   r<   r=   r   r   r<   r<   r>   create_unix_datagram_socket     z(AsyncBackend.create_unix_datagram_socketr%   c                   rj   rX   r<   r   r<   r<   r>   r   "  r   str | bytes | None0UNIXDatagramSocket | ConnectedUNIXDatagramSocketc                   rj   rX   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                  rj   rX   r<   )r=   r}   r   r   r   r   r   r<   r<   r>   getaddrinfo/  s   zAsyncBackend.getaddrinfosockaddrr&   tuple[str, str]c                   rj   rX   r<   )r=   r   r   r<   r<   r>   getnameinfoE  r   zAsyncBackend.getnameinfoobjr   c                   rj   rX   r<   r=   r   r<   r<   r>   wait_readableL  r   zAsyncBackend.wait_readablec                   rj   rX   r<   r   r<   r<   r>   wait_writableQ  r   zAsyncBackend.wait_writablec                 C  rW   rX   r<   r   r<   r<   r>   notify_closingV  r[   zAsyncBackend.notify_closingc                   rj   rX   r<   r   r<   r<   r>   wrap_listener_socket[  r   z!AsyncBackend.wrap_listener_socketc                   rj   rX   r<   r   r<   r<   r>   wrap_stream_socket`  r   zAsyncBackend.wrap_stream_socketc                   rj   rX   r<   r   r<   r<   r>   wrap_unix_stream_sockete  r   z$AsyncBackend.wrap_unix_stream_socketr)   c                   rj   rX   r<   r   r<   r<   r>   wrap_udp_socketj  r   zAsyncBackend.wrap_udp_socketr$   c                   rj   rX   r<   r   r<   r<   r>   wrap_connected_udp_socketo  r   z&AsyncBackend.wrap_connected_udp_socketc                   rj   rX   r<   r   r<   r<   r>   wrap_unix_datagram_sockett  r   z&AsyncBackend.wrap_unix_datagram_socketc                   rj   rX   r<   r   r<   r<   r>   #wrap_connected_unix_datagram_sockety  r   z0AsyncBackend.wrap_connected_unix_datagram_socketc                 C  rW   rX   r<   rB   r<   r<   r>   current_default_thread_limiter  r[   z+AsyncBackend.current_default_thread_limitersignalsr   .AbstractContextManager[AsyncIterator[Signals]]c                 G  rW   rX   r<   )r=   r   r<   r<   r>   open_signal_receiver  rY   z!AsyncBackend.open_signal_receiverr"   c                 C  rW   rX   r<   rB   r<   r<   r>   get_current_task  r[   zAsyncBackend.get_current_taskSequence[TaskInfo]c                 C  rW   rX   r<   rB   r<   r<   r>   get_running_tasks  r[   zAsyncBackend.get_running_tasksc                   rj   rX   r<   rB   r<   r<   r>   wait_all_tasks_blocked  r   z#AsyncBackend.wait_all_tasks_blockedr.   c                 C  rW   rX   r<   )r=   r9   r<   r<   r>   create_test_runner  r[   zAsyncBackend.create_test_runner)
r3   r4   r5   r6   r7   r8   r9   r8   r:   r/   )r:   rA   )r:   rD   )r:   rF   )r:   rH   )rT   rD   r:   rH   )rU   rD   rP   rV   r:   r!   )r:   r-   )r:   r   )r]   rV   r:   r   )r`   ra   r_   rb   r]   rV   r:   r    )rd   rD   r:   r   )FN)
r3   rf   r5   r6   rg   rV   rh   ri   r:   r/   )r3   r4   r5   r6   rn   rA   r:   r/   )r3   rf   r5   r6   rn   rA   r:   r/   )rs   rt   ru   rv   rw   rv   rx   rv   r7   r   r:   r,   )rz   r{   r:   rH   rX   )r}   r~   r   ra   r   r   r:   r(   )r   r   r:   r+   )r   r   r:   r'   )
r   r   r   r   r   r   r   rV   r:   r   )r   r   r   rH   r:   r*   )r   r   r   r   r:   r%   )r   r   r   r   r:   r   )r}   r   r   r   r   r   r   r   r   ra   r   ra   r:   r   )r   )r   r&   r   ra   r:   r   )r   r   r:   rH   )r   r   r:   r(   )r   r   r:   r+   )r   r   r:   r)   )r   r   r:   r$   )r   r   r:   r*   )r   r   r:   r%   )r:   r   )r   r   r:   r   )r:   r"   )r:   r   )r9   r8   r:   r.   )5__name__
__module____qualname__classmethodr   r?   rC   rE   rG   rJ   rO   rS   rR   rM   rN   rQ   rL   rZ   r\   r^   rc   re   rk   rm   rp   rr   ry   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r<   r<   r<   r>   r2   7   s.   			r2   )	metaclass)B
__future__r   rM   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"   _socketsr$   r%   r&   r'   r(   r)   r*   r+   _subprocessesr,   _tasksr-   _testingr.   r/   r0   r~   bytesr1   __annotations__r2   r<   r<   r<   r>   <module>   s:     
	
(
