Skip to content

Commit e91d398

Browse files
committed
PYTHON-2363 Resolve TODO about timeout: <=0 timeout is fine, it means the operation really did timeout in the wait queue
1 parent ead96be commit e91d398

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

pymongo/pool.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,12 @@ def _raise_connection_failure(address, error, msg_prefix=None):
287287
raise AutoReconnect(msg)
288288

289289
if PY3:
290-
def _cond_wait(condition, timeout, deadline):
290+
def _cond_wait(condition, deadline):
291+
timeout = deadline - _time() if deadline else None
291292
return condition.wait(timeout)
292293
else:
293-
def _cond_wait(condition, timeout, deadline):
294+
def _cond_wait(condition, deadline):
295+
timeout = deadline - _time() if deadline else None
294296
condition.wait(timeout)
295297
# Python 2.7 always returns False for wait(),
296298
# manually check for a timeout.
@@ -1322,14 +1324,7 @@ def _get_socket(self, all_credentials):
13221324
with self._max_connecting_cond:
13231325
while (self._pending >= self._max_connecting and
13241326
not self.sockets):
1325-
if self.opts.wait_queue_timeout:
1326-
# TODO: What if timeout is <= zero here?
1327-
# timeout = max(deadline - _time(), .001)
1328-
timeout = deadline - _time()
1329-
else:
1330-
timeout = None
1331-
if not _cond_wait(self._max_connecting_cond,
1332-
timeout, deadline):
1327+
if not _cond_wait(self._max_connecting_cond, deadline):
13331328
# timeout
13341329
emitted_event = True
13351330
self._raise_wait_queue_timeout()

0 commit comments

Comments
 (0)