From 78439ebbe1aae77ff0fd9b666894d80807182e28 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Thu, 1 Jun 2023 16:19:01 +0200 Subject: [PATCH] fix: eventlet compatibility (#3132) Check if poll attribute exists on select module instead of win32 platform check The implementation done in #2865 is breaking usage of docker-py library within eventlet. As per the Python `select.poll` documentation (https://docs.python.org/3/library/select.html#select.poll) and eventlet select removal advice (https://github.com/eventlet/eventlet/issues/608#issuecomment-612359458), it is preferable to use an implementation based on the availability of the `poll()` method that trying to check if the platform is `win32`. Fixes #3131 Signed-off-by: Mathieu Virbel --- docker/utils/socket.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docker/utils/socket.py b/docker/utils/socket.py index efb7458ee..cdc485ea3 100644 --- a/docker/utils/socket.py +++ b/docker/utils/socket.py @@ -3,7 +3,6 @@ import select import socket as pysocket import struct -import sys try: from ..transport import NpipeSocket @@ -32,7 +31,7 @@ def read(socket, n=4096): recoverable_errors = (errno.EINTR, errno.EDEADLK, errno.EWOULDBLOCK) if not isinstance(socket, NpipeSocket): - if sys.platform == 'win32': + if not hasattr(select, "poll"): # Limited to 1024 select.select([socket], [], []) else: