o
    m=8j)                     @  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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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ddZ<edZ=e>e?B ee> B ee? B Z@deAd< G dd dedZBdS )     )annotationsN)ABCMetaabstractmethod)AsyncIterator	AwaitableCallable	CoroutineSequence)AbstractContextManager)PathLike)Signals)AddressFamily
SocketKindsocket)IOTYPE_CHECKINGAny	TypeAliasTypeVaroverload)      )TypeVarTupleUnpack)FileDescriptorLike   )CapacityLimiterEventLock	Semaphore)CancelScope)TaskInfo   )ConnectedUDPSocketConnectedUNIXDatagramSocketIPSockAddrTypeSocketListenerSocketStream	UDPSocketUNIXDatagramSocketUNIXSocketStream)Process)	TaskGroup)
TestRunnerT_RetvalT_coT)	covariantPosArgsTr   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ddKdLZeeddMdNZeeddWdXZeedd[d\Zee	3dddcddZeeddhdiZeeddmdnZeeddodpZeeddvdw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,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 )clsr4   r6   r8   r:   r=   r=   [/home/nk/hobo-godmode/plappi-mvp/.venv/lib/python3.10/site-packages/anyio/abc/_eventloop.pyrun4       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_tokenJ   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_timeT   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?   
checkpointb       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_cancelledl   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_checkpointx   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_cancelled7Callable[[Unpack[PosArgsT]], Coroutine[Any, Any, T_co]]tokenr/   c                 C  rX   rY   r=   r>   r4   r6   rp   r=   r=   r?   run_async_from_thread      z"AsyncBackend.run_async_from_threadc                 C  rX   rY   r=   rq   r=   r=   r?   run_sync_from_thread   rs   z!AsyncBackend.run_sync_from_thread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?   getaddrinfo+  s   zAsyncBackend.getaddrinfosockaddrr%   tuple[str, str]c                   rk   rY   r=   )r>   r   r   r=   r=   r?   getnameinfoA  r   zAsyncBackend.getnameinfoobjr   c                   rk   rY   r=   r>   r   r=   r=   r?   wait_readableH  r   zAsyncBackend.wait_readablec                   rk   rY   r=   r   r=   r=   r?   wait_writableM  r   zAsyncBackend.wait_writablec                 C  rX   rY   r=   r   r=   r=   r?   notify_closingR  r\   zAsyncBackend.notify_closingc                   rk   rY   r=   r   r=   r=   r?   wrap_listener_socketW  r   z!AsyncBackend.wrap_listener_socketc                   rk   rY   r=   r   r=   r=   r?   wrap_stream_socket\  r   zAsyncBackend.wrap_stream_socketc                   rk   rY   r=   r   r=   r=   r?   wrap_unix_stream_socketa  r   z$AsyncBackend.wrap_unix_stream_socketr(   c                   rk   rY   r=   r   r=   r=   r?   wrap_udp_socketf  r   zAsyncBackend.wrap_udp_socketr#   c                   rk   rY   r=   r   r=   r=   r?   wrap_connected_udp_socketk  r   z&AsyncBackend.wrap_connected_udp_socketc                   rk   rY   r=   r   r=   r=   r?   wrap_unix_datagram_socketp  r   z&AsyncBackend.wrap_unix_datagram_socketc                   rk   rY   r=   r   r=   r=   r?   #wrap_connected_unix_datagram_socketu  r   z0AsyncBackend.wrap_connected_unix_datagram_socketc                 C  rX   rY   r=   rC   r=   r=   r?   current_default_thread_limiter|  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_task  r\   zAsyncBackend.get_current_taskSequence[TaskInfo]c                 C  rX   rY   r=   rC   r=   r=   r?   get_running_tasks  r\   zAsyncBackend.get_running_tasksc                   rk   rY   r=   rC   r=   r=   r?   wait_all_tasks_blocked  r   z#AsyncBackend.wait_all_tasks_blockedr-   c                 C  rX   rY   r=   )r>   r:   r=   r=   r?   create_test_runner  r\   zAsyncBackend.create_test_runner)
r4   r5   r6   r7   r8   r9   r:   r9   r;   r.   )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;   r.   )r4   ro   r6   r7   rp   rB   r;   r/   )r4   rg   r6   r7   rp   rB   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;   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   r;   r-   )5__name__
__module____qualname__classmethodr   r@   rD   rF   rH   rK   rP   rT   rS   rN   rO   rR   rM   r[   r]   r_   rd   rf   rl   rn   rr   rt   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?   r3   3   s.   			r3   )	metaclass)C
__future__r   rN   sysabcr   r   collections.abcr   r   r   r   r	   
contextlibr
   osr   signalr   r   r   r   typingr   r   r   r   r   r   version_infor   r   typing_extensions	_typeshedr   _core._synchronizationr   r   r   r   _core._tasksr    _core._testingr!   _socketsr#   r$   r%   r&   r'   r(   r)   r*   _subprocessesr+   _tasksr,   _testingr-   r.   r/   r1   r   bytesr2   __annotations__r3   r=   r=   r=   r?   <module>   s6     
	(
 