summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorCharles-François Natali <cf.natali@gmail.com>2013-09-08 09:30:53 (GMT)
committerCharles-François Natali <cf.natali@gmail.com>2013-09-08 09:30:53 (GMT)
commit45e255167eb8cc34c85439dbdc8074a9b25bec2d (patch)
treebd7600d6ff802cf8b6190dca8c479f51102d7515 /Lib
parent742d8716ff08358a585406cde5b03e71d46968c0 (diff)
downloadcpython-45e255167eb8cc34c85439dbdc8074a9b25bec2d.zip
cpython-45e255167eb8cc34c85439dbdc8074a9b25bec2d.tar.gz
cpython-45e255167eb8cc34c85439dbdc8074a9b25bec2d.tar.bz2
Issue #18934: Use poll/select-based selectors for multiprocessing.Connection,
to avoid one extra FD per Connection.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/multiprocessing/connection.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py
index 59fb664..27fda9f 100644
--- a/Lib/multiprocessing/connection.py
+++ b/Lib/multiprocessing/connection.py
@@ -878,13 +878,21 @@ else:
import selectors
+ # poll/select have the advantage of not requiring any extra file
+ # descriptor, contrarily to epoll/kqueue (also, they require a single
+ # syscall).
+ if hasattr(selectors, 'PollSelector'):
+ _WaitSelector = selectors.PollSelector
+ else:
+ _WaitSelector = selectors.SelectSelector
+
def wait(object_list, timeout=None):
'''
Wait till an object in object_list is ready/readable.
Returns list of those objects in object_list which are ready/readable.
'''
- with selectors.DefaultSelector() as selector:
+ with _WaitSelector() as selector:
for obj in object_list:
selector.register(obj, selectors.EVENT_READ)