+
    iHàjÿ  ã                  ó¦   € R t ^ RIHt ^ RIt^ RIt^ RIHt ^ RIHtH	t	H
t
 ]P                  ! ]4      tRRRRR]P                  /R	 R
 lltR R ltR# )aÄ  Async/sync bridging helpers.

``asyncio.run_coroutine_threadsafe`` can raise ``RuntimeError`` (loop closed during a
shutdown race); the coroutine is then never awaited or closed, which triggers a
"coroutine was never awaited" RuntimeWarning and leaks its frame. The helpers here
close the coroutine on scheduling failure. ``future.result()`` failures are deliberately
NOT handled: once the loop accepts the coroutine its lifecycle belongs to the loop.
)ÚannotationsN)ÚFuture)ÚAnyÚ	CoroutineÚOptionalÚloggerÚlog_messagez$Failed to schedule coroutine on loopÚ	log_levelc               ó0   € V ^8„  d   QhRRRRRRRRR	R
RR/# )é   ÚcorozCoroutine[Any, Any, Any]Úloopz#Optional[asyncio.AbstractEventLoop]r   zOptional[logging.Logger]r   Ústrr	   ÚintÚreturnzOptional[Future]© )Úformats   "Ú6/home/ubuntu/.hermes/hermes-agent/agent/async_utils.pyÚ__annotate__r      sD   € ÷ ñ Ø
"ðØ*Mðà$ðð ðð KNðð ñ	ó    c               ó  € Ve   TM\         p Vf   \        R4      h\        P                  ! W4      #   \         dK   p\        P
                  ! T 4      '       d   T P                  4        TP                  TRY64        Rp?R# Rp?ii ; i)a1  Schedule ``coro`` on ``loop`` from a sync context, leak-safe.

Returns the Future on success, or ``None`` if the loop is missing or scheduling
raised; in every failure path the coroutine is closed. Callers keep full control
over the returned future (``.result(timeout=...)``, callbacks, fire-and-forget).
Nzloop is Nonez%s: %s)Ú_DEFAULT_LOGGERÚRuntimeErrorÚasyncioÚrun_coroutine_threadsafeÚ	ExceptionÚiscoroutineÚcloseÚlog)r   r   r   r   r	   r   Úexcs   &&$$$  r   Úsafe_schedule_threadsafer       ss   € ð Ò&‰&¬O€CðØŠ<Ü˜~Ó.Ð.Ü×/Ò/°Ó;Ð;øÜô Ü×Ò˜t×$Ò$Ø�J‰JŒLØ�‰�	˜8 [Ô6Ýûð	ús   Ž$3 ³B¾?BÂBc               ó    € V ^8„  d   QhRRRR/# )r   Útaskzasyncio.Future[Any]r   ÚNoner   )r   s   "r   r   r   +   s   € ÷ ñ Ð':ð ¸tñ r   c                ól   €  V P                  4        R#   \        P                  \        3 d     R# i ; i)zæ``add_done_callback`` for cancelled-and-detached tasks: observe the exception so the
loop does not log "exception was never retrieved"; cancellation and terminal errors
are swallowed because the task's owner already gave up on it.N)Ú	exceptionr   ÚCancelledErrorr   )r"   s   &r   Úconsume_detached_task_resultr'   +   s.   € ðØ�‰ÖøÜ×"Ñ"¤IÐ.ô Úðús   ‚ ”3²3)Ú__doc__Ú
__future__r   r   ÚloggingÚconcurrent.futuresr   Útypingr   r   r   Ú	getLoggerÚ__name__r   ÚDEBUGr    r'   r   r   r   Ú<module>r0      s^   ðñõ #ã Û Ý %ß +Ñ +ð ×#Ò# HÓ-€ðà'+ðð >ðð QX×P]ÑP]÷÷.r   