-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Fully Compatible
Problems with how we use poll.poll:
- It's not thread safe, yet we use a global poll object and we don't protect calls to poll() with a mutex. If called concurrently an exception is raised. See http://bugs.python.org/issue8865.
- Also, since the poll object is global in the network module, poll() can be called concurrently by multiple connection pools in multiple instances of MongoClient.
- poll() can raise EINTR in versions of Python < 3.5.
- poll() can raise exceptions for various other reasons, which will cause the fd we're polling to never be unregistered.
Solutions:
- Instead of using a global poll object, create a poll object per Pool, or at the very least serialize use of the global object.
- Call poll() in a try / finally calling unregister() in the finally block
- Catch EINTR specifically and retry the call to poll()
While we're fixing poll, also handle EINTR being raised by select.select().
- is depended on by
-
PYTHON-1179 Test failure - various pool tests with pypy(3)
- Closed