diff options
author | I-question-this <tylerofthewest@gmail.com> | 2023-04-21 16:53:58 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-21 17:53:58 -0400 |
commit | a02ba743338c27fd9348af2cf7767b140501734d (patch) | |
tree | 36b7d834e4789b5f6d345f7a8f70e93f98557988 | |
parent | aaf68b7f98df7f886778395112267b9b0f6140bc (diff) | |
download | docker-py-a02ba743338c27fd9348af2cf7767b140501734d.tar.gz |
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 <tylerofthewest@gmail.com>
-rw-r--r-- | docker/utils/socket.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/docker/utils/socket.py b/docker/utils/socket.py index 47cb44f..3c31a98 100644 --- a/docker/utils/socket.py +++ b/docker/utils/socket.py @@ -3,6 +3,7 @@ import os import select import socket as pysocket import struct +import sys try: from ..transport import NpipeSocket @@ -31,7 +32,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'): |