
    %id                    ,   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	 ddgZ
ej                  dk\  rd dlmZ nd dlmZ  e	d	      Zej                  d
k\  rej                  Zyej                  dk\  rddd	 	 	 	 	 	 	 ddZyddd	 	 	 	 	 	 	 ddZddZy)    )annotationsN)Callable	Coroutine)AnyTypeVarasyncio_runiscoroutinefunction)      )r	   _T)r
      )r
      Fdebugloop_factoryc               ~    t        j                  ||      5 }|j                  |       cd d d        S # 1 sw Y   y xY w)Nr   )asyncioRunnerrun)mainr   r   runners       G/usr/local/footviz/venv/lib/python3.12/site-packages/uvicorn/_compat.pyr   r      s5     ^^%lC 	$v::d#	$ 	$ 	$s   3<c                  	 t        j                          t        d      # t        $ r Y nw xY wt        j                  |       st	        d|       |t        j
                         }n |       }	 |t        j                  |       ||j                  |       |j                  |       	 t        |       |j                  |j                                |j                  |j                                |t        j                  d        |j                          S # |t        j                  d        |j                          w xY w# 	 t        |       |j                  |j                                |j                  |j                                |t        j                  d        |j                          w # |t        j                  d        |j                          w xY wxY w)Nz8asyncio.run() cannot be called from a running event loopza coroutine was expected, got )r   get_running_loopRuntimeErroriscoroutine
ValueErrornew_event_loopset_event_loop	set_debugrun_until_complete_cancel_all_tasksshutdown_asyncgensshutdown_default_executorclose)r   r   r   loops       r   r   r   #   s   	[$$& YZZ  		
 ""4(=dXFGG))+D>D	#&&t, u%**40!$'''(?(?(AB''(F(F(HI'**40

  '**40

!$'''(?(?(AB''(F(F(HI'**40

  '**40

s>   ! 	--2:E
 -A	D)E
G)A	F=(G)=)G&&G)c                B   t        j                  |       }|sy |D ]  }|j                           | j                  t        j                  |ddi       |D ]G  }|j                         r|j                         %| j                  d|j                         |d       I y )Nreturn_exceptionsTz1unhandled exception during asyncio.run() shutdown)message	exceptiontask)r   	all_taskscancelr!   gather	cancelledr*   call_exception_handler)r&   	to_cancelr+   s      r   r"   r"   G   s    %%d+	 	DKKM	 		 RT RS 
	D~~~~+++#V%)^^%5 $	
	    )r   zCoroutine[Any, Any, _T]r   boolr   z.Callable[[], asyncio.AbstractEventLoop] | Nonereturnr   )r&   zasyncio.AbstractEventLoopr4   None)
__future__r   r   syscollections.abcr   r   typingr   r   __all__version_infoinspectr	   r   r   r   r"    r2   r   <module>r>      s    "  
 / /
0w++T]w++K 
 GK		$%	$ 	$ E		$
 
	$" GK	"%" " E	"
 
"Hr2   