Skip to content

Commit

Permalink
Use poll() instead of select(), unless Windows.
Browse files Browse the repository at this point in the history
Fixes #2278, which was originally addressed in #2279, but was not
properly merged. Additionally it did not address the problem
of poll not existing on Windows. This patch falls back on the
more limited select method if host system is Windows.

Signed-off-by: Tyler Westland <[email protected]>
  • Loading branch information
I-question-this committed Jul 22, 2021
1 parent a9748a8 commit 69742c4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion docker/utils/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import select
import socket as pysocket
import struct
import sys

try:
from ..transport import NpipeSocket
Expand All @@ -26,7 +27,13 @@ def read(socket, n=4096):
recoverable_errors = (errno.EINTR, errno.EDEADLK, errno.EWOULDBLOCK)

if not isinstance(socket, NpipeSocket):
select.select([socket], [], [])
if sys.platform == 'win32':
# Limited to 1024
select.select([socket], [], [])
else:
poll = select.poll()
poll.register(socket)
poll.poll()

try:
if hasattr(socket, 'recv'):
Expand Down

0 comments on commit 69742c4

Please sign in to comment.