
    dfc	              
           d Z ddlZddlZddlZddlmZ ddlmZ ddlmZm	Z	m
Z
 ddlmZ  ej                           ej                  d      Zded	ed
   de	e   defdZded	ed
   de	e   de
e   ddf
dZy)ze
Some light wrappers around Python's multiprocessing, to deal with cleanly
starting child processes.
    N)SpawnProcess)socket)CallableListOptional)Configspawnconfigtarget).Nsocketsreturnc                     	 t         j                  j                         }| |||d}t        j                  t        |      S # t        $ r d}Y /w xY w)a  
    Called in the parent process, to instantiate a new child process instance.
    The child is not yet started at this point.

    * config - The Uvicorn configuration instance.
    * target - A callable that accepts a list of sockets. In practice this will
               be the `Server.run()` method.
    * sockets - A list of sockets to pass to the server. Sockets are bound once
                by the parent process, and then passed to the child processes.
    Nr
   r   r   stdin_fileno)r   kwargs)sysstdinfilenoOSErrorr	   Processsubprocess_started)r
   r   r   r   r   s        L/home/api-vastappli/venv/lib/python3.12/site-packages/uvicorn/_subprocess.pyget_subprocessr      sZ    $yy'')
 $	F == 26=BB  s   A AAr   c                 v    |t        j                  |      t        _        | j	                           ||       y)a  
    Called when the child process starts.

    * config - The Uvicorn configuration instance.
    * target - A callable that accepts a list of sockets. In practice this will
               be the `Server.run()` method.
    * sockets - A list of sockets to pass to the server. Sockets are bound once
                by the parent process, and then passed to the child processes.
    * stdin_fileno - The file number of sys.stdin, so that it can be reattached
                     to the child process.
    N)r   )osfdopenr   r   configure_loggingr   s       r   r   r   3   s2    $ IIl+	  7    )__doc__multiprocessingr   r   multiprocessing.contextr   r   typingr   r   r   uvicorn.configr   allow_connection_picklingget_contextr	   r   intr    r   r   <module>r(      s     	 
 0  + + ! ) ) ) +###G,CCYC &\C 	CBY &\ 3-	
 
r   