comparison mercurial/keepalive.py @ 41409:1db94ebbc207

keepalive: track ready state with a bool This code may have been written before Python had a bool type. Differential Revision: https://phab.mercurial-scm.org/D5719
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 26 Jan 2019 13:40:44 -0800
parents a43acfa2b76d
children 44d752efdbce
comparison
equal deleted inserted replaced
41408:a43acfa2b76d 41409:1db94ebbc207
154 conn = None 154 conn = None
155 self._lock.acquire() 155 self._lock.acquire()
156 try: 156 try:
157 for c in self._hostmap[host]: 157 for c in self._hostmap[host]:
158 if self._readymap[c]: 158 if self._readymap[c]:
159 self._readymap[c] = 0 159 self._readymap[c] = False
160 conn = c 160 conn = c
161 break 161 break
162 finally: 162 finally:
163 self._lock.release() 163 self._lock.release()
164 return conn 164 return conn
198 h.close() 198 h.close()
199 199
200 def _request_closed(self, request, host, connection): 200 def _request_closed(self, request, host, connection):
201 """tells us that this request is now closed and that the 201 """tells us that this request is now closed and that the
202 connection is ready for another request""" 202 connection is ready for another request"""
203 self._cm.set_ready(connection, 1) 203 self._cm.set_ready(connection, True)
204 204
205 def _remove_connection(self, host, connection, close=0): 205 def _remove_connection(self, host, connection, close=0):
206 if close: 206 if close:
207 connection.close() 207 connection.close()
208 self._cm.remove(connection) 208 self._cm.remove(connection)
235 # no (working) free connections were found. Create a new one. 235 # no (working) free connections were found. Create a new one.
236 h = http_class(host, timeout=self._timeout) 236 h = http_class(host, timeout=self._timeout)
237 if DEBUG: 237 if DEBUG:
238 DEBUG.info("creating new connection to %s (%d)", 238 DEBUG.info("creating new connection to %s (%d)",
239 host, id(h)) 239 host, id(h))
240 self._cm.add(host, h, 0) 240 self._cm.add(host, h, False)
241 self._start_transaction(h, req) 241 self._start_transaction(h, req)
242 r = h.getresponse() 242 r = h.getresponse()
243 # The string form of BadStatusLine is the status line. Add some context 243 # The string form of BadStatusLine is the status line. Add some context
244 # to make the error message slightly more useful. 244 # to make the error message slightly more useful.
245 except httplib.BadStatusLine as err: 245 except httplib.BadStatusLine as err: