Skip to content

Commit a02ba74

Browse files
socket: use poll() instead of select() except on Windows (#2865)
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]>
1 parent aaf68b7 commit a02ba74

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

docker/utils/socket.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import select
44
import socket as pysocket
55
import struct
6+
import sys
67

78
try:
89
from ..transport import NpipeSocket
@@ -31,7 +32,13 @@ def read(socket, n=4096):
3132
recoverable_errors = (errno.EINTR, errno.EDEADLK, errno.EWOULDBLOCK)
3233

3334
if not isinstance(socket, NpipeSocket):
34-
select.select([socket], [], [])
35+
if sys.platform == 'win32':
36+
# Limited to 1024
37+
select.select([socket], [], [])
38+
else:
39+
poll = select.poll()
40+
poll.register(socket)
41+
poll.poll()
3542

3643
try:
3744
if hasattr(socket, 'recv'):

0 commit comments

Comments
 (0)