jazzband / imaplib2

Fork of Piers Lauder's imaplib2 library for Python.
https://imaplib2.readthedocs.io/
MIT License
33 stars 29 forks source link

Do not use TIMEOUT_MAX for Condition.wait() #4

Closed iliastsi closed 3 years ago

iliastsi commented 6 years ago

On some architectures, using threading.TIMEOUT_MAX for the timeout parameter can overflow causing Condition.wait() to return immediately.

As an example, running the following will block on amd64 but return immediately on i386:

Python 3.6.6 (default, Jun 27 2018, 14:44:17)
[GCC 8.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import threading
>>> ready = threading.Event()                                                                        
>>> ready.wait(threading.TIMEOUT_MAX)                                                                
False

Instead of relying on TIMEOUT_MAX, remove it and wait forever. This patch should fix #2 and #3.

nicolas33 commented 5 years ago

Applied in the offlineimap project.