← Back
Editing: fcgi.cpython-311.pyc
� #H\a � �Z � d Z dZdZddlZddlmZmZ ddlmZ dgZ G d� dee� � Z dS ) ax fcgi - a FastCGI/WSGI gateway. For more information about FastCGI, see <http://www.fastcgi.com/>. For more information about the Web Server Gateway Interface, see <http://www.python.org/peps/pep-0333.html>. Example usage: #!/usr/bin/env python from myapplication import app # Assume app is your WSGI application object from fcgi import WSGIServer WSGIServer(app).run() See the documentation for WSGIServer for more information. On most platforms, fcgi will fallback to regular CGI behavior if run in a non-FastCGI context. If you want to force CGI behavior, set the environment variable FCGI_FORCE_CGI to "Y" or "y". zAllan Saddi <allan@saddi.com>z $Revision$� N)�BaseFCGIServer�FCGI_RESPONDER)�ThreadedServer� WSGIServerc �: � e Zd ZdZdddddddefdf d�Zd� Zd� ZdS )r z| FastCGI server that supports the Web Server Gateway Interface. See <http://www.python.org/peps/pep-0333.html>. NTFc � � t j | ||||||||| | �� � dD ] }||v r||= � t j | f| j | fd�|�� dS )a� environ, if present, must be a dictionary-like object. Its contents will be copied into application's environ. Useful for passing application-specific variables. bindAddress, if present, must either be a string or a 2-tuple. If present, run() will open its own listening socket. You would use this if you wanted to run your application as an 'external' FastCGI app. (i.e. the webserver would no longer be responsible for starting your app) If a string, it will be interpreted as a filename and a UNIX socket will be opened. If a tuple, the first element, a string, is the interface name/IP to bind to, and the second element (an int) is the port number. ) �environ� multithreaded�multiprocess�bindAddress�umask�multiplexed�debug�roles�forceCGI)�jobClass�jobArgsN)r �__init__r �_connectionClass) �self�applicationr r r r r r r r r �kw�keys �2/usr/lib/python3/dist-packages/flup/server/fcgi.pyr zWSGIServer.__init__@ s� � �$ ���k�(/�.;�-9�,7�&+�,7�&+�&+�)1� 3� 3� 3� 3� +� � �C��b�y�y��s�G����� 7�t�/D�)-�� 7� 7�35� 7� 7� 7� 7� 7� c �X � | j d u p!t |� � dk o|d | j v S )N� r )�_web_server_addrs�len)r �addrs r �_isClientAllowedzWSGIServer._isClientAllowedb s7 � ��%��-� F��D� � �Q��D�4��7�d�.D�#D� Fr c �4 � t j � d� � | _ | j �.t d� | j � d� � � � | _ | � � � }t j | |� � }| � |� � |S )z� The main loop. Exits on SIGHUP, SIGINT, SIGTERM. Returns True if SIGHUP was received, False otherwise. �FCGI_WEB_SERVER_ADDRSNc �* � | � � � S )N)�strip)�xs r �<lambda>z WSGIServer.run.<locals>.<lambda>m s � �1�7�7�9�9� r �,) �osr �getr �map�split�_setupSocketr �run�_cleanupSocket)r �sock�rets r r. zWSGIServer.runf s� � � "$����0G�!H�!H����!�-�%(�)<�)<�)-�)?�)E�)E�c�)J�)J�&L� &L�D�"� � � �"�"��� ��t�,�,�����D�!�!�!�� r )�__name__� __module__�__qualname__�__doc__r r r! r. � r r r r ; so � � � � � �� � -1�#�%�!��5��N�#4�u� 7� 7� 7� 7�DF� F� F�� � � � r )r5 � __author__�__version__r) �flup.server.fcgi_baser r �flup.server.threadedserverr �__all__r r6 r r �<module>r<