o
    fe'                     @  sv  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
 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mZmZ ejd	krXd 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" ddl#m$Z$ ddl%m&Z& ddl'm(Z( ddl)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7 edZ8edZ9G dd dedZ:dS )    )annotationsN)ABCMetaabstractmethod)AsyncIterator	AwaitableMapping)PathLike)Signals)AddressFamily
SocketKindsocket)IOTYPE_CHECKINGAnyCallableContextManagerSequenceTypeVaroverload)      )TypeVarTupleUnpack)Literal   )CapacityLimiterEvent)CancelScope)TaskInfo)BlockingPortal   )ConnectedUDPSocketConnectedUNIXDatagramSocketIPSockAddrTypeSocketListenerSocketStream	UDPSocketUNIXDatagramSocketUNIXSocketStream)Process)	TaskGroup)
TestRunnerT_RetvalPosArgsTc                   @  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		3ddd8d9Zeedd:d;Zeedd=d>Zeedd?d@ZeeddBdCZeed3d3ddDddSdTZeed3d3ddDddWdTZeed3d3ddDddYdTZeedd\d]Zee	3dddedf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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 )clsr/   r1   r3   r5   r8   r8   L/var/www/NoticeGen/venv/lib/python3.10/site-packages/anyio/abc/_eventloop.pyrun4       zAsyncBackend.runobjectc                 C  r7   )z

        :return:
        Nr8   r9   r8   r8   r:   current_tokenJ   r<   zAsyncBackend.current_tokenfloatc                 C  r7   )zz
        Return the current value of the event loop's internal clock.

        :return: the clock value (seconds)
        Nr8   r>   r8   r8   r:   current_timeR   r<   zAsyncBackend.current_timetype[BaseException]c                 C  r7   )zFReturn the exception class that is raised in a task if it's cancelled.Nr8   r>   r8   r8   r:   cancelled_exception_class[   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`.
        Nr8   r>   r8   r8   r:   
checkpoint`       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infrF   r>   r8   r8   r:   checkpoint_if_cancelledj   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sleepr>   r8   r8   r:   cancel_shielded_checkpointv   s   	"z'AsyncBackend.cancel_shielded_checkpointdelayc                   rE   )zt
        Pause the current task for the specified duration.

        :param delay: the duration, in seconds
        Nr8   )r9   rP   r8   r8   r:   rN      rG   zAsyncBackend.sleepF)deadlinerL   rQ   rL   boolr   c                C     d S Nr8   )r9   rQ   rL   r8   r8   r:   rM         z AsyncBackend.create_cancel_scopec                 C  r7   )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
        Nr8   r>   r8   r8   r:   rH      r<   z'AsyncBackend.current_effective_deadliner*   c                 C  rS   rT   r8   r>   r8   r8   r:   create_task_group      zAsyncBackend.create_task_groupr   c                 C  rS   rT   r8   r>   r8   r8   r:   create_event   rW   zAsyncBackend.create_eventtotal_tokensr   c                 C  rS   rT   r8   )r9   rY   r8   r8   r:   create_capacity_limiter   rW   z$AsyncBackend.create_capacity_limiterN&Callable[[Unpack[PosArgsT]], T_Retval]abandon_on_cancellimiterCapacityLimiter | Nonec                      d S rT   r8   )r9   r/   r1   r\   r]   r8   r8   r:   run_sync_in_worker_thread      	z&AsyncBackend.run_sync_in_worker_threadc                 C  rS   rT   r8   r>   r8   r8   r:   check_cancelled   rW   zAsyncBackend.check_cancelledtokenc                 C  rS   rT   r8   r9   r/   r1   rc   r8   r8   r:   run_async_from_thread      z"AsyncBackend.run_async_from_threadc                 C  rS   rT   r8   rd   r8   r8   r:   run_sync_from_thread   rf   z!AsyncBackend.run_sync_from_threadr   c                 C  rS   rT   r8   r>   r8   r8   r:   create_blocking_portal   rW   z#AsyncBackend.create_blocking_portal)cwdenvstart_new_sessioncommandstr | bytesshellLiteral[True]stdinint | IO[Any] | Nonestdoutstderrri   "str | bytes | PathLike[str] | Nonerj   Mapping[str, str] | Nonerk   r)   c          	        r_   rT   r8   	r9   rl   rn   rp   rr   rs   ri   rj   rk   r8   r8   r:   open_process      zAsyncBackend.open_processSequence[str | bytes]Literal[False]c          	        r_   rT   r8   rv   r8   r8   r:   rw      rx   #str | bytes | Sequence[str | bytes]c          	        r_   rT   r8   rv   r8   r8   r:   rw      rx   workersset[Process]c                 C  rS   rT   r8   )r9   r|   r8   r8   r:   #setup_process_pool_exit_at_shutdown  rW   z0AsyncBackend.setup_process_pool_exit_at_shutdownhoststrportintlocal_addressIPSockAddrType | Noner%   c                   r_   rT   r8   )r9   r   r   r   r8   r8   r:   connect_tcp     zAsyncBackend.connect_tcppathr(   c                   r_   rT   r8   )r9   r   r8   r8   r:   connect_unix     zAsyncBackend.connect_unixsockr   r$   c                 C  rS   rT   r8   r9   r   r8   r8   r:   create_tcp_listener  rW   z AsyncBackend.create_tcp_listenerc                 C  rS   rT   r8   r   r8   r8   r:   create_unix_listener  rW   z!AsyncBackend.create_unix_listenerfamilyr
   remote_address
reuse_portUDPSocket | ConnectedUDPSocketc                   r_   rT   r8   )r9   r   r   r   r   r8   r8   r:   create_udp_socket#  ra   zAsyncBackend.create_udp_socket
raw_socketremote_pathr'   c                   r_   rT   r8   r9   r   r   r8   r8   r:   create_unix_datagram_socket.     z(AsyncBackend.create_unix_datagram_socketr"   c                   r_   rT   r8   r   r8   r8   r:   r   4  r   str | bytes | None0UNIXDatagramSocket | ConnectedUNIXDatagramSocketc                   r_   rT   r8   r   r8   r8   r:   r   :  r   r   )r   typeprotoflagsbytes | str | Nonestr | int | Noneint | AddressFamilyr   int | SocketKindr   r   ]list[tuple[AddressFamily, SocketKind, int, str, tuple[str, int] | tuple[str, int, int, int]]]c                  r_   rT   r8   )r9   r   r   r   r   r   r   r8   r8   r:   getaddrinfoA  s   zAsyncBackend.getaddrinfosockaddrr#   tuple[str, str]c                   r_   rT   r8   )r9   r   r   r8   r8   r:   getnameinfoW  r   zAsyncBackend.getnameinfoc                   r_   rT   r8   r   r8   r8   r:   wait_socket_readable^  r   z!AsyncBackend.wait_socket_readablec                   r_   rT   r8   r   r8   r8   r:   wait_socket_writablec  r   z!AsyncBackend.wait_socket_writablec                 C  rS   rT   r8   r>   r8   r8   r:   current_default_thread_limiterh  rW   z+AsyncBackend.current_default_thread_limitersignalsr	   &ContextManager[AsyncIterator[Signals]]c                 G  rS   rT   r8   )r9   r   r8   r8   r:   open_signal_receiverm  rU   z!AsyncBackend.open_signal_receiverr   c                 C  rS   rT   r8   r>   r8   r8   r:   get_current_taskt  rW   zAsyncBackend.get_current_taskSequence[TaskInfo]c                 C  rS   rT   r8   r>   r8   r8   r:   get_running_tasksy  rW   zAsyncBackend.get_running_tasksc                   r_   rT   r8   r>   r8   r8   r:   wait_all_tasks_blocked~  r   z#AsyncBackend.wait_all_tasks_blockedr+   c                 C  rS   rT   r8   )r9   r5   r8   r8   r:   create_test_runner  rW   zAsyncBackend.create_test_runner)
r/   r0   r1   r2   r3   r4   r5   r4   r6   r,   )r6   r=   )r6   r@   )r6   rB   )r6   rD   )rP   r@   r6   rD   )rQ   r@   rL   rR   r6   r   )r6   r*   )r6   r   )rY   r@   r6   r   )FN)
r/   r[   r1   r2   r\   rR   r]   r^   r6   r,   )r/   r0   r1   r2   rc   r=   r6   r,   )r/   r[   r1   r2   rc   r=   r6   r,   )r6   r   )rl   rm   rn   ro   rp   rq   rr   rq   rs   rq   ri   rt   rj   ru   rk   rR   r6   r)   )rl   ry   rn   rz   rp   rq   rr   rq   rs   rq   ri   rt   rj   ru   rk   rR   r6   r)   )rl   r{   rn   rR   rp   rq   rr   rq   rs   rq   ri   rt   rj   ru   rk   rR   r6   r)   )r|   r}   r6   rD   rT   )r   r   r   r   r   r   r6   r%   )r   rm   r6   r(   )r   r   r6   r$   )
r   r
   r   r   r   r   r   rR   r6   r   )r   r   r   rD   r6   r'   )r   r   r   rm   r6   r"   )r   r   r   r   r6   r   )r   r   r   r   r   r   r   r   r   r   r   r   r6   r   )r   )r   r#   r   r   r6   r   )r   r   r6   rD   )r6   r   )r   r	   r6   r   )r6   r   )r6   r   )r5   r4   r6   r+   ),__name__
__module____qualname__classmethodr   r;   r?   rA   rC   rF   rK   rO   rN   rI   rJ   rM   rH   rV   rX   rZ   r`   rb   re   rg   rh   r   rw   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r8   r8   r8   r:   r.   3   s   					r.   )	metaclass);
__future__r   rI   sysabcr   r   collections.abcr   r   r   osr   signalr	   r   r
   r   typingr   r   r   r   r   r   r   r   version_infor   r   typing_extensionsr   _core._synchronizationr   r   _core._tasksr   _core._testingr   from_threadr   _socketsr!   r"   r#   r$   r%   r&   r'   r(   _subprocessesr)   _tasksr*   _testingr+   r,   r-   r.   r8   r8   r8   r:   <module>   s2    (
(
