Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/tornado/__pycache__/wsgi.cpython-39.pyc
Ðазад
a _�hF � @ s� d Z ddlZddlmZ ddlZddlmZ ddlmZ ddlmZ ddl m Z mZmZm Z mZmZmZ ddlmZ ddl Z e jr�dd l mZ dd lmZ eed�dd �ZG dd� de�ZejZdS )a WSGI support for the Tornado web framework. WSGI is the Python standard for web servers, and allows for interoperability between Tornado and other Python web frameworks and servers. This module provides WSGI support via the `WSGIContainer` class, which makes it possible to run applications using other WSGI frameworks on the Tornado HTTP server. The reverse is not supported; the Tornado `.Application` and `.RequestHandler` classes are designed for use with the Tornado `.HTTPServer` and cannot be used in a generic WSGI container. � N)�BytesIO)�escape)�httputil)� access_log)�List�Tuple�Optional�Callable�Any�Dict�Text)� TracebackType)�Type)�WSGIApplication)�s�returnc C s t | t�sJ �| �d�S )N�latin1)� isinstance�bytes�decode)r � r �|/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/tornado/wsgi.py�to_wsgi_str3 s r c @ sd e Zd ZdZddd�dd�Zejdd�dd �Zeeje e ef d�d d��Ze ejdd�d d�ZdS )� WSGIContainera� Makes a WSGI-compatible function runnable on Tornado's HTTP server. .. warning:: WSGI is a *synchronous* interface, while Tornado's concurrency model is based on single-threaded asynchronous execution. This means that running a WSGI app with Tornado's `WSGIContainer` is *less scalable* than running the same app in a multi-threaded WSGI server like ``gunicorn`` or ``uwsgi``. Use `WSGIContainer` only when there are benefits to combining Tornado and WSGI in the same process that outweigh the reduced scalability. Wrap a WSGI function in a `WSGIContainer` and pass it to `.HTTPServer` to run it. For example:: def simple_app(environ, start_response): status = "200 OK" response_headers = [("Content-type", "text/plain")] start_response(status, response_headers) return ["Hello world!\n"] container = tornado.wsgi.WSGIContainer(simple_app) http_server = tornado.httpserver.HTTPServer(container) http_server.listen(8888) tornado.ioloop.IOLoop.current().start() This class is intended to let other frameworks (Django, web.py, etc) run on the Tornado HTTP server and I/O loop. The `tornado.web.FallbackHandler` class is often useful for mixing Tornado and WSGI apps in the same server. See https://github.com/bdarnell/django-tornado-demo for a complete example. �WSGIAppTypeN)�wsgi_applicationr c C s || _ d S �N)r )�selfr r r r �__init__[ s zWSGIContainer.__init__)�requestr c s� i � g �dt ttt t f ttdtt tt f ttgtf d�� �fdd� }| � t �|�|�}z*��|� d� ��}W t|d�r�|�� nt|d�r�|�� 0 � s�td��� d �d d �\}}t|�}� d }tdd � |D ��} t�|�}|dk�r,d| v�r|�dt t|��f� d| v�r,|�d� d| v�rJ|�ddtj f� t�d||�} t�� }|D ]\}} |�|| � �qd|jd u�s�J �|jj| ||d� |j� � | �!||� d S )NzOptional[Type[BaseException]])�status�headers�exc_infor c s | � d<