File: //opt/saltstack/salt/lib/python3.10/site-packages/cheroot/__pycache__/wsgi.cpython-310.pyc
o
�N�g: � @ s� d Z ddlmZmZmZ eZddlZddlZddl m
Z
ddlmZ ddl
mZ ddlmZmZ G d d
� d
ej�ZG dd� dej�ZG d
d� de�ZG dd� de�Ze�� ZG dd� d�Ze� jeeeeed� dS )a� This class holds Cheroot WSGI server implementation.
Simplest example on how to use this server::
from cheroot import wsgi
def my_crazy_app(environ, start_response):
status = '200 OK'
response_headers = [('Content-type','text/plain')]
start_response(status, response_headers)
return [b'Hello world!']
addr = '0.0.0.0', 8070
server = wsgi.Server(addr, my_crazy_app)
server.start()
The Cheroot WSGI server can serve as many WSGI applications
as you want in one instance by using a PathInfoDispatcher::
path_map = {
'/': my_crazy_app,
'/blog': my_blog_app,
}
d = wsgi.PathInfoDispatcher(path_map)
server = wsgi.Server(addr, d)
� )�absolute_import�division�print_functionN)�filter� )�server)�
threadpool)�ntob�btonc sJ e Zd ZdZdZ d
� fdd � Zed
d� �Zejdd� �Z� Z S )�Serverz8A subclass of HTTPServer which calls a WSGI application.�r r �
N���� Fc
sV t t| �j|t| j |||d� || _|| _|| _|| _t j
| |p"d|| |
d�| _dS )a� Initialize WSGI Server instance.
Args:
bind_addr (tuple): network interface to listen to
wsgi_app (callable): WSGI application callable
numthreads (int): number of threads for WSGI thread pool
server_name (str): web server name to be advertised via
Server HTTP header
max (int): maximum number of worker threads
request_queue_size (int): the 'backlog' arg to
socket.listen(); max queued connections
timeout (int): the timeout in seconds for accepted connections
shutdown_timeout (int): the total time, in seconds, to
wait for worker threads to cleanly exit
accepted_queue_size (int): maximum number of active
requests in queue
accepted_queue_timeout (int): timeout for putting request
into queue
)Zgateway�server_name�peercreds_enabled�peercreds_resolve_enabledr )�min�max�accepted_queue_size�accepted_queue_timeoutN)�superr �__init__�
wsgi_gateways�wsgi_version�wsgi_app�request_queue_size�timeout�shutdown_timeoutr Z
ThreadPool�requests)
�self� bind_addrr �
numthreadsr r r r r r r r r �� __class__� �@/opt/saltstack/salt/lib/python3.10/site-packages/cheroot/wsgi.pyr / s
�
�zServer.__init__c C s | j jS )zSet minimum number of threads.�r r �r r% r% r&