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rÃd 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d¬d
d„ƒƒZeed­dd„ƒƒZeed®dd„ƒƒZeed¯dd„ƒƒZeed°dd„ƒƒZ	ed°dd„ƒZ
ed°dd„ƒZeed±dd„ƒƒZeeejdd œd²d%d&„ƒƒZeed®d'd(„ƒƒZeed³d*d+„ƒƒZeed´d-d.„ƒƒZeedµd1d2„ƒƒZeed3dd4œd¶d:d;„ƒƒZeed·d>d?„ƒƒZee		3d¸d¹dDdE„ƒƒZeed°dFdG„ƒƒZeedºdIdJ„ƒƒZeed»dKdL„ƒƒZeed¼dNdO„ƒƒZeed½dXdY„ƒƒZeed¾d\d]„ƒƒZee	3d¿dÀddde„ƒƒZeedÁdidj„ƒƒZeedÂdndo„ƒƒZeedÂdpdq„ƒƒZ eedÃdwdx„ƒƒZ!ee"dÄd|d}„ƒƒZ#ee"dÅdd}„ƒƒZ#eedÆd‚d}„ƒƒZ#eedƒdƒdƒdƒd„œdÇd�dŽ„ƒƒZ$ee	ƒdÈdÉd’d“„ƒƒZ%eedÊd–d—„ƒƒZ&eedÊd˜d™„ƒƒZ'eedËdšd›„ƒƒZ(eedÌdŸd „ƒƒZ)eedÍd¢d£„ƒƒZ*eedÎd¥d¦„ƒƒZ+eed°d§d¨„ƒƒZ,eedÏdªd«„ƒƒZ-d3S )ÐÚAsyncBackendÚfuncú1Callable[[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=   úJC:\Users\shubh\Videos\agent\nova\Lib\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 | Noneú0UNIXDatagramSocket | 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   Ztyping_extensionsr   Z	_typeshedr   Z_core._synchronizationr   r   r   r    Z_core._tasksr!   Z_core._testingr"   Zfrom_threadr#   Ú_socketsr%   r&   r'   r(   r)   r*   r+   r,   Z_subprocessesr-   Ú_tasksr.   Z_testingr/   r0   r1   r€   Úbytesr2   Ú__annotations__r3   r=   r=   r=   r?   Ú<module>   s<     
	
(
