From 69742c4a3f8e813adb04f5d16318607e14fc5654 Mon Sep 17 00:00:00 2001 From: Tyler Westland Date: Thu, 22 Jul 2021 16:04:31 -0400 Subject: [PATCH] Use poll() instead of select(), unless Windows. 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 --- docker/utils/socket.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docker/utils/socket.py b/docker/utils/socket.py index 4a2076ec4..e92ea15f5 100644 --- a/docker/utils/socket.py +++ b/docker/utils/socket.py @@ -3,6 +3,7 @@ import select import socket as pysocket import struct +import sys try: from ..transport import NpipeSocket @@ -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'):