Ticket #3420: updates.diff
File updates.diff, 2.6 KB (added by , 8 years ago) |
---|
-
client.py
627 627 SSL context objects for any SSL connections the agent needs to make. 628 628 629 629 @ivar persistent: Set to C{True} when you use HTTP persistent connecton. 630 @type persistent: Boolean630 @type persistent: C{bool} 631 631 632 @ivar maxConnections : Max number of HTTP connections per a server. The633 default value is 1. This is effective only when the632 @ivar maxConnectionsPerHostName: Max number of HTTP connections per a server. The 633 default value is 2. This is effective only when the 634 634 C{self.persistent} is C{True}. 635 635 RFC 2616 says "A single-user client SHOULD NOT maintain more than 2 636 636 connections with any server or proxy." 637 @type maxConnections : C{int}637 @type maxConnectionsPerHostName: C{int} 638 638 639 639 @ivar _semaphores: A dictioinary mapping a tuple (scheme, host, port) 640 640 to an instance of L{DeferredSemaphore}. It is used to limit the … … 647 647 @since: 9.0 648 648 """ 649 649 _protocol = HTTP11ClientProtocol 650 maxConnections = 1650 maxConnectionsPerHostName = 2 651 651 652 652 def __init__(self, reactor, contextFactory=WebClientContextFactory(), 653 persistent=False ):653 persistent=False, maxConnectionsPerHostName=2): 654 654 self._reactor = reactor 655 655 self._contextFactory = contextFactory 656 656 self.persistent = persistent 657 self.maxConnectionsPerHostName = maxConnectionsPerHostName 657 658 self._semaphores = {} 658 659 self._protocolCache = {} 659 660 … … 739 740 if self.persistent: 740 741 sem = self._semaphores.get((scheme, host, port)) 741 742 if sem is None: 742 sem = defer.DeferredSemaphore(self.maxConnections )743 sem = defer.DeferredSemaphore(self.maxConnectionsPerHostName) 743 744 self._semaphores[scheme, host, port] = sem 744 745 return sem.run(self._request, method, scheme, host, port, path, 745 746 headers, bodyProducer) … … 808 809 # Previous connection is unavailable. 809 810 if f.check(ResponseFailed): 810 811 for reason in f.value.reasons: 811 if (isinstance(reason, failure.Failure) and 812 if (isinstance(reason, failure.Failure) and 812 813 isinstance(reason.value, ConnectionDone)): 813 814 # Maybe timeout has been exeeded before I send 814 815 # the request. So I retry again.