##// END OF EJS Templates
url: allow to configure timeout on http connection...
Cédric Krier -
r40079:6509fcec default
parent child Browse files
Show More
@@ -737,6 +737,11 b" coreconfigitem('http_proxy', 'passwd',"
737 737 coreconfigitem('http_proxy', 'user',
738 738 default=None,
739 739 )
740
741 coreconfigitem('http', 'timeout',
742 default=None,
743 )
744
740 745 coreconfigitem('logtoprocess', 'commandexception',
741 746 default=None,
742 747 )
@@ -1322,6 +1322,15 b' proxy.'
1322 1322 Optional. Always use the proxy, even for localhost and any entries
1323 1323 in ``http_proxy.no``. (default: False)
1324 1324
1325 ``http``
1326 ----------
1327
1328 Used to configure access to Mercurial repositories via HTTP.
1329
1330 ``timeout``
1331 If set, blocking operations will timeout after that many seconds.
1332 (default: None)
1333
1325 1334 ``merge``
1326 1335 ---------
1327 1336
@@ -172,8 +172,9 b' class ConnectionManager(object):'
172 172 return dict(self._hostmap)
173 173
174 174 class KeepAliveHandler(object):
175 def __init__(self):
175 def __init__(self, timeout=None):
176 176 self._cm = ConnectionManager()
177 self._timeout = timeout
177 178 self.requestscount = 0
178 179 self.sentbytescount = 0
179 180
@@ -234,7 +235,7 b' class KeepAliveHandler(object):'
234 235 h = self._cm.get_ready_conn(host)
235 236 else:
236 237 # no (working) free connections were found. Create a new one.
237 h = http_class(host)
238 h = http_class(host, timeout=self._timeout)
238 239 if DEBUG:
239 240 DEBUG.info("creating new connection to %s (%d)",
240 241 host, id(h))
@@ -317,8 +317,8 b' class logginghttpconnection(keepalive.HT'
317 317
318 318 class logginghttphandler(httphandler):
319 319 """HTTP handler that logs socket I/O."""
320 def __init__(self, logfh, name, observeropts):
321 super(logginghttphandler, self).__init__()
320 def __init__(self, logfh, name, observeropts, timeout=None):
321 super(logginghttphandler, self).__init__(timeout=timeout)
322 322
323 323 self._logfh = logfh
324 324 self._logname = name
@@ -365,8 +365,8 b' if has_https:'
365 365 sslutil.validatesocket(self.sock)
366 366
367 367 class httpshandler(keepalive.KeepAliveHandler, urlreq.httpshandler):
368 def __init__(self, ui):
369 keepalive.KeepAliveHandler.__init__(self)
368 def __init__(self, ui, timeout=None):
369 keepalive.KeepAliveHandler.__init__(self, timeout=timeout)
370 370 urlreq.httpshandler.__init__(self)
371 371 self.ui = ui
372 372 self.pwmgr = passwordmgr(self.ui,
@@ -525,18 +525,19 b' def opener(ui, authinfo=None, useragent='
525 525 ``sendaccept`` allows controlling whether the ``Accept`` request header
526 526 is sent. The header is sent by default.
527 527 '''
528 timeout = ui.configwith(float, 'http', 'timeout')
528 529 handlers = []
529 530
530 531 if loggingfh:
531 532 handlers.append(logginghttphandler(loggingfh, loggingname,
532 loggingopts or {}))
533 loggingopts or {}, timeout=timeout))
533 534 # We don't yet support HTTPS when logging I/O. If we attempt to open
534 535 # an HTTPS URL, we'll likely fail due to unknown protocol.
535 536
536 537 else:
537 handlers.append(httphandler())
538 handlers.append(httphandler(timeout=timeout))
538 539 if has_https:
539 handlers.append(httpshandler(ui))
540 handlers.append(httpshandler(ui, timeout=timeout))
540 541
541 542 handlers.append(proxyhandler(ui))
542 543
General Comments 0
You need to be logged in to leave comments. Login now