Ë
    R/j²  ã                  óà   — d Z ddlmZ ddlZddlZddlZddl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 d	ZdZdZdd„Zdd„Z	 	 	 	 	 	 	 	 dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zy) 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                óH   — | j                  «       s| j                  d«       yy)z'Set a future to None if it is not done.N)ÚdoneÚ
set_result)Úfuts    úI/home/josh/.local/lib/python3.12/site-packages/zeroconf/_utils/asyncio.pyÚ_set_future_none_if_not_doner   *   s   € à�8‰8Œ:Ø�‰�tÕð ó    c                óH   — | D ]  }t        |«       Œ | j                  «        y)zResolve all futures to None.N)r   Úclear)Úfuturesr   s     r   Ú_resolve_all_futures_to_noner   0   s"   € àò *ˆÜ$ SÕ)ð*à‡M�M…Or   c              ƒ  ó6  K  — | j                  «       }|j                  |«       | j                  t        |«      t        |«      }	 |ƒ d{  –—†  |j                  «        |j                  |«       y7 Œ&# |j                  «        |j                  |«       w xY w­w)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Ø‡N�N�6ÔØ�_‰_Ô.¨wÓ7Ô9UÐW]Ó^€Fð#Ø�ˆà�‰ŒØ×Ñ˜6Õ"ð 	ùà�‰ŒØ×Ñ˜6Õ"üs0   ‚ABÁA3 Á
A1ÁA3 Á"BÁ1A3 Á3#BÂBc              ƒ  ól  K  — t        j                  «       }|j                  |t        | «      }	 | ƒ d{  –—†  |j                  «        y7 Œ# t         j                  $ r= t
        j                  dk\  r't        j                  «       x}r|j                  «       r‚ Y Œbw xY w# |j                  «        w xY w­w)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Ô&BÀFÓK€FðØ�ˆð
 	�‰�ð 	ùÜ×!Ñ!ò Ü×Ñ˜wÒ&´G×4HÑ4HÓ4JÐ,J¨DÐ,JÐPT×P_ÑP_ÔPaØùðûð 	�‰�üsD   ‚,B4¯A ´A
µA ¹B4Á
A ÁABÂB ÂBÂB ÂB1Â1B4c              ƒ  ó  K  — t        j                  d«      ƒ d{  –—†  t        d«      D ];  }t        j                  t
        «      5  t        j                  | «      cddd«       c S  t        «       S 7 ŒW# 1 sw Y   ŒSxY w­w)zReturn all tasks running.r   Nr   )r&   ÚsleepÚrangeÚ
contextlibÚsuppressÚRuntimeErrorÚ	all_tasksÚset)r   Ú_s     r   Ú_async_get_all_tasksr8   R   sq   è ø€ ä
�-‰-˜Ó
×Ðô �1‹Xò +ˆÜ× Ñ ¤Ó.ñ 	+Ü×$Ñ$ TÓ*÷	+ó 	+ð+ô ‹5€Lð ø÷
	+ð 	+üs'   ‚B›A3œ+BÁA5ÁBÁ5A>	Á:Bc              ƒ  óV   K  — t        j                  | t        ¬«      ƒ d{  –—†  y7 Œ­w)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              ƒ  ó<   K  — | ƒ d{  –—† }|ƒ d{  –—†  y7 Œ7 Œ­w)z-Wait on an awaitable and the task it returns.N© )Úawr-   s     r   Úawait_awaitablerA   c   s   è ø€ à�8€DØ
‡J�Jð øØús   ‚ˆ‰	’“šc                óÆ   — 	 t        j                  | |«      j                  t        |«      t        z   «      S # t
        j                  j                  $ r}t        |‚d}~ww xY w)aw  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   s[   € ð'Ü×/Ñ/°°DÓ9×@Ñ@Ü˜gÓ&Ô)?Ñ?ó
ð 	
øô ×Ñ×*Ñ*ò 'Ü BÐ&ûð'ús   ‚47 ·A ÁAÁA c                ój  — t        t        j                  t        | «      | «      j	                  t
        «      «      }||D �ch c]  }|j                  «       sŒ|’Œ c}z  }|r2t        j                  t        |«      | «      j	                  t        «       | j                  | j                  «       yc c}w )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Ó)CÀTÓJ×QÑQÔRhÓió€Mð  }ÖD˜t¸¿	¹	½’dÒDÑD€MÙÜ×(Ñ(Ô)=¸mÓ)LÈdÓS×ZÑZÜ(ô	
ð 	×Ñ˜dŸi™iÕ(ùò Es   ÁB0ÁB0c                 óˆ   — t        j                  t        «      5  t        j                  «       cddd«       S # 1 sw Y   yxY w)z*Check if an event loop is already running.N)r2   r3   r4   r&   r'   r?   r   r   r'   r'   ‰   s4   € ä	×	Ñ	œ\Ó	*ñ *Ü×'Ñ'Ó)÷*÷ *ñ *àús	   š8¸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   