Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/werkzeug/middleware/__pycache__/profiler.cpython-39.pyc
Ðазад
a ^�h# � @ s� d Z ddlZddlZddlZddlZddlmZ zddl m Z W n ey^ ddlm Z Y n0 ej r�ddlmZ ddlmZ ddlmZ G dd � d �ZdS ) a9 Application Profiler ==================== This module provides a middleware that profiles each request with the :mod:`cProfile` module. This can help identify bottlenecks in your code that may be slowing down your application. .. autoclass:: ProfilerMiddleware :copyright: 2007 Pallets :license: BSD-3-Clause � N)�Stats)�Profile)� StartResponse)�WSGIApplication)�WSGIEnvironmentc @ st e Zd ZdZejddddfdeje ej e ej ej eeef ej e edd�dd �Zd dej e d�d d�ZdS )�ProfilerMiddlewarea Wrap a WSGI application and profile the execution of each request. Responses are buffered so that timings are more exact. If ``stream`` is given, :class:`pstats.Stats` are written to it after each request. If ``profile_dir`` is given, :mod:`cProfile` data files are saved to that directory, one file per request. The filename can be customized by passing ``filename_format``. If it is a string, it will be formatted using :meth:`str.format` with the following fields available: - ``{method}`` - The request method; GET, POST, etc. - ``{path}`` - The request path or 'root' should one not exist. - ``{elapsed}`` - The elapsed time of the request. - ``{time}`` - The time of the request. If it is a callable, it will be called with the WSGI ``environ`` dict and should return a filename. :param app: The WSGI application to wrap. :param stream: Write stats to this stream. Disable with ``None``. :param sort_by: A tuple of columns to sort stats by. See :meth:`pstats.Stats.sort_stats`. :param restrictions: A tuple of restrictions to filter stats by. See :meth:`pstats.Stats.print_stats`. :param profile_dir: Save profile data files to this directory. :param filename_format: Format string for profile data file names, or a callable returning a name. See explanation above. .. code-block:: python from werkzeug.middleware.profiler import ProfilerMiddleware app = ProfilerMiddleware(app) .. versionchanged:: 0.15 Stats are written even if ``profile_dir`` is given, and can be disable by passing ``stream=None``. .. versionadded:: 0.15 Added ``filename_format``. .. versionadded:: 0.9 Added ``restrictions`` and ``profile_dir``. )�timeZcalls� Nz/{method}.{path}.{elapsed:.0f}ms.{time:.0f}.profr )�app�stream�sort_by�restrictions�profile_dir�filename_format�returnc C s( || _ || _|| _|| _|| _|| _d S �N)�_app�_stream�_sort_by� _restrictions�_profile_dir�_filename_format)�selfr r r r r r r r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/werkzeug/middleware/profiler.py�__init__M s zProfilerMiddleware.__init__r r )�environ�start_responser c sD g �d��fdd� � d d�� ���fdd�}t � }t�� }|�|� d���}t�� | }�jd ur�t�j�rz����}n6�jj�d �d �d �� d d �p�d|d t�� d �}t j��j|�}|�|� �j d u�r>t|�j d�} | j�j� td�j d� ��dd�} td| ���j d� | j�j� td� d��j d� |gS )Nc s �| ||� � j S r )�append)�status�headers�exc_info)� response_bodyr r r �catching_start_responseb s z<ProfilerMiddleware.__call__.<locals>.catching_start_response)r c s4 �� �t�d� ��} ��| � t| d�r0| �� d S )Nr �close)r �t�cast�extend�hasattrr# )Zapp_iter)r"