o
    Ci~	                     @  s   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
mZ ddlmZ e  edZdddZdddZdS )ze
Some light wrappers around Python's multiprocessing, to deal with cleanly
starting child processes.
    )annotationsN)SpawnProcess)socket)CallableOptional)Configspawnconfigr   targetCallable[..., None]socketslist[socket]returnr   c                 C  sB   zt j }W n ty   d}Y nw | |||d}tjt|d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OSErrorr   Processsubprocess_started)r	   r
   r   r   r    r   k/var/www/html/fyndo/python/python_agents/rag_suite/venv/lib/python3.10/site-packages/uvicorn/_subprocess.pyget_subprocess   s   r   r   
int | NoneNonec                 C  s*   |dur
t |t_|   ||d dS )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   r   r   r   r   5   s   r   )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   r   uvicorn.configr   allow_connection_picklingget_contextr   r   r   r   r   r   r   <module>   s    

!