
    n&ph0                     H    S SK JrJr  S SKJr  S SKJr  S rS	SSSS.S jjrg)
    )get_event_loopiscoroutine)wraps)	signaturec                 V   #    U " U0 UD6n[        U5      (       a  UI Sh  vN   gg N7f)a  
This helper function launches an async main function that was tagged with
forever=True. There are two possibilities:

- The function is a normal function, which handles initializing the event
  loop, which is then run forever
- The function is a coroutine, which needs to be scheduled in the event
  loop, which is then run forever
  - There is also the possibility that the function is a normal function
    wrapping a coroutine function

The function is therefore called unconditionally and scheduled in the event
loop if the return value is a coroutine object.

The reason this is a separate function is to make absolutely sure that all
the objects created are garbage collected after all is said and done; we
do this to ensure that any exceptions raised in the tasks are collected
ASAP.
N)r   )coroargskwargsloopthings        [/var/www/html/venv/lib/python3.13/site-packages/setuptools/_vendor/autocommand/autoasync.py_run_forever_coror      s0     4 $!&!E5 s   )')NFr   forever	pass_loopc                   ^ ^^^^^ T c  UUU4S j$ T(       a9  [        T 5      mTR                  S TR                  R                  5        5       S9m[	        T 5      U UUUUU4S j5       nT(       a  TUl        U$ )a  
Convert an asyncio coroutine into a function which, when called, is
evaluted in an event loop, and the return value returned. This is intented
to make it easy to write entry points into asyncio coroutines, which
otherwise need to be explictly evaluted with an event loop's
run_until_complete.

If `loop` is given, it is used as the event loop to run the coro in. If it
is None (the default), the loop is retreived using asyncio.get_event_loop.
This call is defered until the decorated function is called, so that
callers can install custom event loops or event loop policies after
@autoasync is applied.

If `forever` is True, the loop is run forever after the decorated coroutine
is finished. Use this for servers created with asyncio.start_server and the
like.

If `pass_loop` is True, the event loop object is passed into the coroutine
as the `loop` kwarg when the wrapper function is called. In this case, the
wrapper function's __signature__ is updated to remove this parameter, so
that autoparse can still be used on it without generating a parameter for
`loop`.

This coroutine can be called with ( @autoasync(...) ) or without
( @autoasync ) arguments.

Examples:

@autoasync
def get_file(host, port):
    reader, writer = yield from asyncio.open_connection(host, port)
    data = reader.read()
    sys.stdout.write(data.decode())

get_file(host, port)

@autoasync(forever=True, pass_loop=True)
def server(host, port, loop):
    yield_from loop.create_server(Proto, host, port)

server('localhost', 8899)

c                    > [        U TTTS9$ )Nr   )	autoasync)cr   r   r   s    r   <lambda>autoasync.<locals>.<lambda>c   s    D!    c              3   :   #    U  H  u  pUS :w  d  M  Uv   M     g7f)r   N ).0nameparams      r   	<genexpr>autoasync.<locals>.<genexpr>n   s"      .%?kdv~ E%?s   	)
parametersc            	        > Tc
  [        5       OTnT	(       a_  TR                  5       nUR                  R                  " SSU0TR                  " U 0 UD6R                  D6  UR
                  UR                  pT(       a-  UR                  [        TXU5      5        UR                  5         g UR                  T" U 0 UD65      $ )Nr   r   )r   bind_partial	argumentsupdatebindr	   r
   create_taskr   run_foreverrun_until_complete)
r	   r
   
local_loop
bound_argsr   r   r   new_sigold_sigr   s
       r   autoasync_wrapper$autoasync.<locals>.autoasync_wrapperr   s     *.^%4
  --/J  '' ;;,,//99; &??J,=,=&""#4dJ$  ""$00t1Fv1FGGr   )r   replacer    itemsr   __signature__)r   r   r   r   r-   r+   r,   s   ```` @@r   r   r   6   s    X |! 	! D/// .%,%7%7%=%=%?./   4[H H H0 *1'r   )N)	asyncior   r   	functoolsr   inspectr   r   r   r   r   r   <module>r5      s'   $ 0  >Xu Xr   