HEX
Server: Apache
System: Linux p102.lithium.hosting 4.18.0-553.141.1.el8_10.x86_64 #1 SMP Fri Jul 10 17:48:02 UTC 2026 x86_64
User: bvzmoamr (9955)
PHP: 8.1.34
Disabled: syslog
Upload Files
File: //usr/lib64/python2.7/site-packages/mercurial/keepalive.pyc
�
1�3\c@@s�dZddlmZmZddlZddlZddlZddlZddlZddl	m
Z
ddlmZm
Z
mZmZddlmZejZejZejZdadefd	��YZd
efd��YZdeejfd
��YZdejfd��YZd�Zd�Zdejfd��YZd�Z d�Z!dd�Z"d�Z#dd�Z$e%dkr�ddl&Z&y$e'ej(d�Z)ej(dZ*Wn,e+e,fk
r�e-dej(d�q�Xe$e*e)�ndS(sKAn 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.
i(tabsolute_importtprint_functionNi(t_(tnodetpycompatturllibcompattutil(tprocutiltConnectionManagercB@sGeZdZd�Zd�Zd�Zd�Zd�Zdd�Z	RS(sV
    The connection manager must be able to:
      * keep track of all existing
      cC@s.tj�|_i|_i|_i|_dS(N(t	threadingtLockt_lockt_hostmapt_connmapt	_readymap(tself((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyt__init__ss		cC@ss|jj�zQ||jkr/g|j|<n|j|j|�||j|<||j|<Wd|jj�XdS(N(RtacquireRtappendR
Rtrelease(Rthostt
connectiontready((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pytaddys

cC@s�|jj�zky|j|}Wntk
r4nCX|j|=|j|=|j|j|�|j|sw|j|=nWd|jj�XdS(N(RRR
tKeyErrorRRtremoveR(RRR((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyR�s




cC@s)y||j|<Wntk
r$nXdS(N(RR(RRR((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyt	set_ready�s
cC@szd}|jj�zR||jkrdx<|j|D]*}|j|r3d|j|<|}Pq3q3WnWd|jj�X|S(Ni(tNoneRRRRR(RRtconntc((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pytget_ready_conn�s


cC@s0|rt|jj|g��St|j�SdS(N(tlistRtgettdict(RR((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pytget_all�sN(
t__name__t
__module__t__doc__RRRRRRR"(((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyRns					tKeepAliveHandlercB@sheZdd�Zd�Zd�Zd�Zd�Zdd�Zd�Z	d�Z
d	�Zd
�ZRS(cC@s+t�|_||_d|_d|_dS(Ni(Rt_cmt_timeoutt
requestscounttsentbytescount(Rttimeout((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyR�s		cC@s8g|jj�j�D]\}}|t|�f^qS(streturn a list of connected hosts and the number of connections
        to each.  [('foo.com:80', 2), ('bar.org', 1)](R'R"titemstlen(RRtli((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pytopen_connections�scC@s;x4|jj|�D] }|jj|�|j�qWdS(s�close connection(s) to <host>
        host is the host:port spec, as in 'www.cnn.com:8080' as passed in.
        no error occurs if there is no connection to that host.N(R'R"Rtclose(RRth((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pytclose_connection�scC@sUxN|jj�j�D]7\}}x(|D] }|jj|�|j�q)WqWdS(sclose all open connectionsN(R'R"t	iteritemsRR0(RRtconnsR1((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyt	close_all�s"
cC@s|jj|d�dS(setells us that this request is now closed and that the
        connection is ready for another requestiN(R'R(RtrequestRR((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyt_request_closed�sicC@s'|r|j�n|jj|�dS(N(R0R'R(RRRR0((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyt_remove_connection�s
cC@s|jt|�S(N(tdo_opentHTTPConnection(Rtreq((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyt	http_open�scC@stj|�}|s'tjd��ny�|jj|�}x�|r�|j|||�}|rdPn|j�|jj|�|jj|�}q?W||d|j	�}t
r�t
jd|t|��n|jj
||d�|j||�|j�}Wnhtjk
r;}tjtd�tj|j���n.tjtjfk
rh}tj|��nXt|dt�r�|jj|�nt
r�t
jd|j|j�n||_||_|j�|_ ||_!|j|_"|j#|_$|j|_#|S(Ns
no host givenR+s"creating new connection to %s (%d)isbad HTTP status line: %st
will_closesSTATUS: %s, %s(%RtgethostturlerrturlerrorR'Rt_reuse_connectionR0RR(tDEBUGtinfotidRt_start_transactiontgetresponsethttplibt
BadStatusLineRRtsysbytestlinetsocketterrort
HTTPExceptiontgetattrtTruetstatustreasont_handlert_hosttget_full_urlt_urlt_connectiontcodetmsgtheaders(Rt
http_classR;RR1trterr((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyR9�sH	
	"			cC@s�y |j||�|j�}Wnhtjtjfk
rEd}nFtrjtjd|t|��n|j	j
|�|j��nX|dks�|jdkr�tr�tj
d|t|��nd}n"tr�tj
d|t|��n|S(sGstart the transaction with a re-used connection
        return a response object (r) upon success or None on failure.
        This DOES not close or remove bad connections in cases where
        it returns.  However, if an unexpected exception occurs, it
        will close and remove the connection before re-raising.
        s4unexpected exception - closing connection to %s (%d)i	s&failed to re-use connection to %s (%d)sre-using connection to %s (%d)N(RERFRKRLRGRMRRBRDR'RR0tversionRC(RR1R;RR[((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyRAs(	
	
		cC@skt|dd�}tj|jj�}|jt|jj���|jt|j	j���tjd�|j�D��}i}x7dD]/}||kr�d|d|j
dd	�<q�q�Wy�tj|�rLtj
|�}|j|j�tj|�|�d
|kr |jdd�nd
|krn|jddt|��qnn"|j|j�tj|�|�Wn%tjk
r�}tj|��nXx*|j�D]\}	}
|j|	|
�q�W|j�tj|�r�|j|�n|jd7_|jt|dd�|7_y8|jjd7_|jjt|dd�|7_Wntk
rfnXdS(NR*ics@s'|]\}}|j�|fVqdS(N(tlower(t.0tntv((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pys	<genexpr>FsRsaccept-encodingitskip_t-Rscontent-typesContent-types!application/x-www-form-urlencodedscontent-lengthsContent-lengths%d(Rsaccept-encoding(RNRtsortdicttparentt
addheaderstupdatetsortedRYR,tunredirected_hdrstreplaceRthasdatatgetdatat
putrequestt
get_methodtgetselectort	putheaderR-RKRLR?R@t
endheaderstsendR)R*tAttributeError(RR1R;t
oldbytescountRYtskipheadersR`tdataR\tkRa((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyRE=sL
!	
 


N(
R#R$RRR/R2R5R7R8R<R9RARE(((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyR&�s						7	.tHTTPHandlercB@seZRS((R#R$(((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyRxmstHTTPResponsecB@s�eZdddd�ZejjZeejdd�Z	d�Z
d�Zd�Zd�Z
dd�Zd�Zd	�Zdd
�Zd�ZRS(
icC@s�i}tjs&t|d<t|d<ntjj||d|d||�|j|_d|_d|_	d|_
d|_d|_d|_
d|_d|_dS(Ntstrictt	bufferingt
debugleveltmethoditi�(Rtispy3RORGRyRtfilenoRRWtreceivedbytescountt_rbuft	_rbufsizeRRRSRURV(RtsockR|RzR}textrakw((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyR�s	


							treadintocC@sN|jrJ|jj�d|_|jrJ|jj||j|j�qJndS(N(tfpR0RRRR7RSRV(R((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyR0�s	
		cC@s-|jj|j|jdd�|j�dS(NR0i(RRR8RSRVR0(R((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyR2�scC@s|jS(N(RY(R((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyRC�scC@s|jS(N(RU(R((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pytgeturl�scC@s|jra|dk	rat|j�}||kr=||8}qa|j| }|j||_|Sn|j}d|_|j|�}|jt|�7_y|jjt|�7_Wntk
r�nXy|jjjt|�7_Wntk
r�nX||7}|S(NR~(	R�RR-t	_raw_readR�RVRsRRRe(RtamttLtsRv((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pytread�s*

		


cC@s�|j}g}x�tr�|dkr�|jj�}|jd�}|dkr[|| }nyt|d�}Wn3tk
r�|j�t	j
dj|���nX|dkr�Pq�n|dkr�|j|j
|��n�||kr|j|j
|��|||_dj|�S||kr]|j|j
|��|j
d�d|_dj|�S|j|j
|��||8}|j
d�d}qWx3tr�|jj�}|s�Pn|dkr�Pq�q�W|j�dj|�S(Nt;iiR~is
(t
chunk_leftRORR�treadlinetfindtintt
ValueErrorR0RGtIncompleteReadtjoinRt
_safe_read(RR�R�tpartsRJti((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyt
_read_chunked�sL		





	



	
cC@sr|jjd�}|dkrI|d7}|j| }|j||_|S|jg}d}|j}x�tr|j|�}|s�Pn|jt|�7_|jjt|�7_y|jj	jt|�7_Wnt
k
r�nX|j|�|jd�}|dkrgPqgqgW|dkr8d|_dj|�S|d7}|d||_|d| |d<dj|�S(Ns
iii����R~(
R�R�R�ROR�R�R-RVRRReRsRR�(RR�RJtchunkstreadsizetnew((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyR�s<

		

	

cC@sfd}g}xStra|j�}|s+Pn|j|�|t|�7}|r||krPqqW|S(Ni(ROR�RR-(RtsizehintttotalRRJ((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyt	readlines*s	
cC@s7|jdkrK|jt|��}|s.dS||dt|�+t|�St|�}t|j�}||kr�|j| |d|+|j||_|St|�}|j|||!�}|j|7_|jj|7_y|jj|7_Wnt	k
rnX|j|d|+|t|j�7}d|_|S(NiR~(
t
_raw_readintoRR�R-R�t
memoryviewR�RVRRRs(RtdesttresR�thavetmvtgot((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyR�7s0

	N(R#R$RRRGRyR�R�RNR�R0R2RCR�R�R�R�R�(((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyRyps				 	6	*
cC@s�t|dd�dk	rdS|jdkrM|jrA|j�qMtj�n|jdkrrtdt	|��ny�d}t|dd�}|dk	r|jdkr�td�n||�}xc|r�|jj
|�|jt|�7_||�}q�Wn%|jj
|�|jt|�7_Wn{t
jk
r�}t}|dtjkr�|jtjkr�d|_|j�|_t}n|j�n|r��q�nXdS(s`Send `str' to the server.

    Shamelessly ripped off from httplib to patch a bad behavior.
    t_broken_pipe_respNissend:i R�ssending a read()able(RNRR�t	auto_opentconnectRGtNotConnectedR|tprinttreprtsendallR*R-RKRLROterrnotEPIPEt_HTTPConnection__statet_CS_REQ_SENTR�RFtFalseR0(Rtstrt	blocksizeR�RvRatreraise((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pytsafesendSs>	

			
c@s"�fd�}�jj|_|S(s>Wraps getresponse in cls with a broken-pipe sane version.
    c@s/t|dd�}|dk	r"|S�j|�S(NR�(RNRRF(RR[(tcls(s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pytsafegetresponse�s(RFR%(R�R�((R�s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pytwrapgetresponse�s	R:cB@s,eZeZeZeej�Z	d�Z
RS(cO@s,tjj|||�d|_d|_dS(Ni(RGR:RR*R�(Rtargstkwargs((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyR�s	(R#R$Rytresponse_classR�RrR�RGR:RFR(((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyR:�scC@sntj}d}tj�}tj|�tj|�}|j�}|j�||�}t|dt	j
|j��f�tjt��}tj|�tj|�}|j�}|j�||�}t|dt	j
|j��f�tj|�}d}x*t
r0|j�}|r,||}qPqW|j�||�}t|dt	j
|j��f�dS(Ns%25s: %ss
normal urllibskeepalive readR~skeepalive readline(thashlibtmd5turlreqtbuildopenert
installopenerturlopenR�R0R�RthextdigestRxROR�(turlR�tformattopenertfotfootmtf((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyt
continuity�s4	

#

#	

cC@s�td||f�tjjd�tj�}tj|�t||�}td|�tjjd�tjt��}tj|�t||�}td|�td||�dS(Ns   making %i connections to:
  %ss(  first using the normal urllib handlerss  TIME: %.3f ss(  now using the keepalive handler       s  improvement factor: %.2f(	R�RtstdouttwriteR�R�R�tfetchRx(tNR�R�tt1tt2((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pytcomp�s

cC@s�ddl}g}|j�}xnt|�D]`}|rS|dkrS|j|�ntj|�}|j�}|j�|jt|��q+W|j�|}	d}
xC|dD]7}|
d}
||dks�t	d|
|f�q�q�W|	S(Niis+WARNING: inconsistent length on read %i: %i(
ttimetrangetsleepR�R�R�R0RR-R�(R�R�tdelayR�tlenst	starttimeR�R�R�tdifftj((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyR��s"

cC@st}dtfd��Y}|�atd�tj|�}|j�}|j�d}td|�xH|dkr�tjj	d|�tjj
�tjd�|d8}qkWtj
j	d	�td
�tj|�}|j�}|j�||krtd�n
td�|adS(
Nt
FakeLoggercB@seZd�ZeZZZRS(cW@st||�dS(N(R�(RRXR�((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pytdebug�s(R#R$R�RCtwarningRL(((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyR��s	s-  fetching the file to establish a connectionis;  waiting %i seconds for the server to close the connectionis
  %2iis
s!  fetching the file a second times  data are identicals  ERROR: DATA DIFFER(RBtobjectR�R�R�R�R0RR�R�tflushR�R�tstderr(R�tdbbackupR�R�tdata1R�tdata2((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyttest_timeout�s.	







i
cC@sWtd�t|�td�td�t||�td�td�t|�dS(Ns>performing continuity test (making sure stuff isn't corrupted)R~sperforming speed comparisons#performing dropped-connection check(R�R�R�R�(R�R�((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyttests






t__main__is%s <integer> <url>(.R%t
__future__RRR�R�RKtsysR	ti18nRR~RRRRtutilsRRGR?R�RRBR�RR&thttphandlerRxRyR�R�R:R�R�R�R�R�R#R�R�targvR�R�t
IndexErrorR�R�(((s9/usr/lib64/python2.7/site-packages/mercurial/keepalive.pyt<module>QsB"			@��	5		#		#