
    g
                        d Z ddlm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
 ddlmZ  ej                      ej        d          ZddZddZdS )ze
Some light wrappers around Python's multiprocessing, to deal with cleanly
starting child processes.
    )annotationsN)SpawnProcess)socket)Callable)Configspawnconfigr   targetCallable[..., None]socketslist[socket]returnr   c                    	 t           j                                        }n# t          t          f$ r d}Y nw xY w| |||d}t
                              t          |          S )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AttributeErrorOSErrorr   Processsubprocess_started)r	   r
   r   r   r   s        E/var/www/html/env/lib/python3.11/site-packages/uvicorn/_subprocess.pyget_subprocessr      sx    "y''))G$    $	 F == 26=BBBs   ! 77r   
int | NoneNonec                    |t          j        |          t          _        |                                  	  ||           dS # t
          $ r Y dS w xY w)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_loggingKeyboardInterruptr   s       r   r   r   6   sq    $ Il++	 w    	s   A 
AA)r	   r   r
   r   r   r   r   r   )
r	   r   r
   r   r   r   r   r   r   r   )__doc__
__future__r   multiprocessingr   r   multiprocessing.contextr   r   typingr   uvicorn.configr   allow_connection_picklingget_contextr   r   r        r   <module>r-      s    
 # " " " " "     				 



 0 0 0 0 0 0             ! ! ! ! ! ! ) ) + + +##G,,C C C CB     r,   