1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
From: Ilias Tsitsimpis <iliastsi@debian.org>
Date: Sat, 25 Aug 2018 09:43:41 +0300
Subject: Do not use TIMEOUT_MAX
On some architectures, using threading.TIMEOUT_MAX for the timeout
parameter can overflow causing Condition.wait() to return immediately.
Instead of relying on TIMEOUT_MAX, remove it and wait forever.
Bug-Debian: https://bugs.debian.org/899102
Bug: https://github.com/imaplib2/imaplib2/issues/3
Forwarded: https://github.com/imaplib2/imaplib2/pull/4
---
imaplib2.py | 5 ++---
imaplib2.py3 | 4 ++--
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/imaplib2.py b/imaplib2.py
index 1fd47d2..3a8b6c0 100755
--- a/imaplib2.py
+++ b/imaplib2.py
@@ -67,7 +67,6 @@ if bytes != str:
else:
import Queue as queue
string_types = basestring
- threading.TIMEOUT_MAX = 9223372036854.0
select_module = select
@@ -192,7 +191,7 @@ class Request(object):
def get_response(self, exc_fmt=None):
self.callback = None
if __debug__: self.parent._log(3, '%s:%s.ready.wait' % (self.name, self.tag))
- self.ready.wait(threading.TIMEOUT_MAX)
+ self.ready.wait()
if self.aborted is not None:
typ, val = self.aborted
@@ -1391,7 +1390,7 @@ class IMAP4(object):
self.commands_lock.release()
if need_event:
if __debug__: self._log(3, 'sync command %s waiting for empty commands Q' % name)
- self.state_change_free.wait(threading.TIMEOUT_MAX)
+ self.state_change_free.wait()
if __debug__: self._log(3, 'sync command %s proceeding' % name)
if self.state not in Commands[name][CMD_VAL_STATES]:
diff --git a/imaplib2.py3 b/imaplib2.py3
index 0aeff4d..e02f094 100755
--- a/imaplib2.py3
+++ b/imaplib2.py3
@@ -182,7 +182,7 @@ class Request(object):
def get_response(self, exc_fmt=None):
self.callback = None
if __debug__: self.parent._log(3, '%s:%s.ready.wait' % (self.name, self.tag))
- self.ready.wait(threading.TIMEOUT_MAX)
+ self.ready.wait()
if self.aborted is not None:
typ, val = self.aborted
@@ -1316,7 +1316,7 @@ class IMAP4(object):
self.commands_lock.release()
if need_event:
if __debug__: self._log(3, 'sync command %s waiting for empty commands Q' % name)
- self.state_change_free.wait(threading.TIMEOUT_MAX)
+ self.state_change_free.wait()
if __debug__: self._log(3, 'sync command %s proceeding' % name)
if self.state not in Commands[name][CMD_VAL_STATES]:
|