Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/lib64/python3.9/site-packages/mercurial/__pycache__/ |
Upload File : |
a �+�bjl � @ s� d Z ddlmZmZ ddlZddlZddlZddlZddlZddl Z ddl mZ ddlm Z ddlmZ ddlmZmZmZ dd lmZ ejZejZejZdaG d d� de�ZG dd � d e�ZG dd� deej�ZG dd� dej�Zdd� Zdd� Z G dd� dej!�Z!dd� Z"dd� Z#d&dd�Z$dd� Z%d'd!d"�Z&e'd#k�r�ddl(Z(ze)ej*d �Z+ej*d$ Z,W n* e-e.f�y� e/d%ej*d � Y n0 e&e,e+� dS )(aK An HTTP handler for urllib2 that supports HTTP 1.1 and keepalive. >>> import urllib2 >>> from keepalive import HTTPHandler >>> keepalive_handler = HTTPHandler() >>> opener = urlreq.buildopener(keepalive_handler) >>> urlreq.installopener(opener) >>> >>> fo = urlreq.urlopen('http://www.python.org') If a connection to a given host is requested, and all of the existing connections are still in use, another connection will be opened. If the handler tries to use an existing connection but it fails in some way, it will be closed and removed from the pool. To remove the handler, simply re-run build_opener with no arguments, and install that opener. You can explicitly close connections by using the close_connection() method of the returned file-like object (described below) or you can use the handler methods: close_connection(host) close_all() open_connections() NOTE: using the close_connection and close_all methods of the handler should be done with care when using multiple threads. * there is nothing that prevents another thread from creating new connections immediately after connections are closed * no checks are done to prevent in-use connections from being closed >>> keepalive_handler.close_all() EXTRA ATTRIBUTES AND METHODS Upon a status of 200, the object returned has a few additional attributes and methods, which should not be used if you want to remain consistent with the normal urllib2-returned objects: close_connection() - close the connection to the host readlines() - you know, readlines() status - the return status (i.e. 404) reason - english translation of status (i.e. 'File not found') If you want the best of both worlds, use this inside an AttributeError-catching try: >>> try: status = fo.status >>> except AttributeError: status = None Unfortunately, these are ONLY there if status == 200, so it's not easy to distinguish between non-200 responses. The reason is that urllib2 tries to do clever things with error codes 301, 302, 401, and 407, and it wraps the object upon return. � )�absolute_import�print_functionN� )�_)�getattr)�hex)�pycompat�urllibcompat�util)�procutilc @ sB e Zd ZdZdd� Zdd� Zdd� Zdd � Zd d� Zdd d�Z dS )�ConnectionManagerzT The connection manager must be able to: * keep track of all existing c C s&