mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #18934: Use poll/select-based selectors for multiprocessing.Connection,
to avoid one extra FD per Connection.
This commit is contained in:
parent
742d8716ff
commit
45e255167e
1 changed files with 9 additions and 1 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue