
    i                        S r SSKJr  SSKrSSKrSSKrSSKrSSKJ	r	J
r
  SSKJr  SSKJr  SSKJr  S	S
KJr  S	rSrSrSS jrSS jr        SS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrg) a  Multicast DNS Service Discovery for Python, v0.14-wmcbrine
Copyright 2003 Paul Scott-Murphy, 2014 William McBrine

This module provides a framework for the use of DNS Service Discovery
using IP multicast.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
    )annotationsN)	Awaitable	Coroutine)Any   )EventLoopBlocked)_LOADED_SYSTEM_TIMEOUT   )millis_to_seconds   c                R    U R                  5       (       d  U R                  S5        gg)z'Set a future to None if it is not done.N)done
set_result)futs    N/home/sebas/venvs/catt/lib/python3.13/site-packages/zeroconf/_utils/asyncio.py_set_future_none_if_not_doner   *   s    88::t     c                L    U  H  n[        U5        M     U R                  5         g)zResolve all futures to None.N)r   clear)futuresr   s     r   _resolve_all_futures_to_noner   0   s    $S) MMOr   c                6  #    U R                  5       nUR                  U5        U R                  [        U5      [        U5      n UI Sh  vN   UR                  5         UR                  U5        g N&! UR                  5         UR                  U5        f = f7f)z/Wait for a future or timeout (in milliseconds).N)create_futureadd
call_laterr   r   canceldiscard)loop
future_settimeoutfuturehandles        r   wait_for_future_set_or_timeoutr#   7   s{      !FNN6__.w79UW]^F#6" 	6"s0   ABA3 
A1A3 "B1A3 3#BBc                  #    [         R                  " 5       nUR                  U[        U 5      n U I Sh  vN   UR                  5         g N! [         R                   aI    [
        R                  S:  a2  [         R                  " 5       =n(       a  UR                  5       (       a  e  Nof = f! UR                  5         f = f7f)zWait for a future or timeout.N)r      )
asyncioget_running_loopr   r   CancelledErrorsysversion_infocurrent_task
cancellingr   )r!   r    r   r"   tasks        r   wait_future_or_timeoutr.   E   s     ##%D__W&BFKF
 	 	!! w&G4H4H4J,JD,JPTP_P_PaPa 	sD   -CA AA CA AB*'B- )B**B- -B??Cc                  #    [         R                  " S5      I Sh  vN   [        S5       H=  n[        R                  " [
        5         [         R                  " U 5      sSSS5        s  $    [        5       $  NZ! , (       d  f       M\  = f7f)zReturn all tasks running.r   Nr   )r&   sleeprange
contextlibsuppressRuntimeError	all_tasksset)r   _s     r   _async_get_all_tasksr8   R   sa     
--
 1X  .$$T* /.  5L 
 /.s'   BA7,B	A9B9
B	Bc                R   #    [         R                  " U [        S9I Sh  vN   g N7f)z6Wait for the event loop thread we started to shutdown.)r    N)r&   wait_TASK_AWAIT_TIMEOUT)
wait_taskss    r   _wait_for_loop_tasksr=   ^   s     
,,z+>
???s   '%'c                <   #    U I Sh  vN nUI Sh  vN   g N N7f)z-Wait on an awaitable and the task it returns.N )awr-   s     r   await_awaitablerA   c   s     8D
JJ s   	c                     [         R                  " X5      R                  [        U5      [        -   5      $ ! [
        R                  R                   a  n[        UeSnAff = f)a[  Run a coroutine with a timeout.

The timeout should only be used as a safeguard to prevent
the program from blocking forever. The timeout should
never be expected to be reached during normal operation.

While not expected during normal operations, the
function raises `EventLoopBlocked` if the coroutine takes
longer to complete than the timeout.
N)	r&   run_coroutine_threadsaferesultr   r	   
concurrentr   TimeoutErrorr   )r@   r   r    exs       r   run_coro_with_timeoutrH   i   sY    '//9@@g&)??
 	
 ** 'B&'s   47 A!AA!c                   [        [        R                  " [        U 5      U 5      R	                  [
        5      5      nX Vs1 s H  o"R                  5       (       d  M  UiM     sn-  nU(       a3  [        R                  " [        U5      U 5      R	                  [        5        U R                  U R                  5        gs  snf )z.Wait for pending tasks and stop an event loop.N)r6   r&   rC   r8   rD   _GET_ALL_TASKS_TIMEOUTr   r=   _WAIT_FOR_LOOP_TASKS_TIMEOUTcall_soon_threadsafestop)r   pending_tasksr-   s      r   shutdown_looprO   |   s    (()=d)CTJQQRhiM }D}t		d}DDM(()=m)LdSZZ(	
 	dii( Es   B>B>c                     [         R                  " [        5         [        R                  " 5       sSSS5        $ ! , (       d  f       g= f)z*Check if an event loop is already running.N)r2   r3   r4   r&   r'   r?   r   r   r'   r'      s+    			\	*'') 
+	*	*s	   :
A)r   zasyncio.FuturereturnNone)r   set[asyncio.Future]rQ   rR   )r   asyncio.AbstractEventLoopr   rS   r    floatrQ   rR   )r!   zasyncio.Future[bool | None]r    rU   rQ   rR   )r   rT   rQ   set[asyncio.Task])r<   rV   rQ   rR   )r@   r   rQ   rR   )r@   r   r   rT   r    rU   rQ   r   )r   rT   rQ   rR   )rQ   z asyncio.AbstractEventLoop | None) __doc__
__future__r   r&   concurrent.futuresrE   r2   r)   collections.abcr   r   typingr   _exceptionsr   constr	   timer   r;   rJ   rK   r   r   r#   r.   r8   r=   rA   rH   rO   r'   r?   r   r   <module>r_      s   , #    
 0  * * #     #
##1D#OT#	#
	@
'&
)r   