Skip to content

Commit

Permalink
vendored Docker SDK for Python code: fix: eventlet compatibility
Browse files Browse the repository at this point in the history
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 (eventlet/eventlet#608 (comment)), 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 docker/docker-py#3131

Cherry-picked from docker/docker-py@78439eb

Co-authored-by: Mathieu Virbel <mat@meltingrocks.com>
  • Loading branch information
felixfontein and tito committed Oct 7, 2023
1 parent 37bc40e commit a92a7f2
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions plugins/module_utils/_api/utils/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import select
import socket as pysocket
import struct
import sys

from ansible.module_utils.six import PY3, binary_type

Expand Down Expand Up @@ -43,7 +42,7 @@ def read(socket, n=4096):
recoverable_errors = (errno.EINTR, errno.EDEADLK, errno.EWOULDBLOCK)

if PY3 and not isinstance(socket, NpipeSocket):
if sys.platform == 'win32':
if not hasattr(select, "poll"):
# Limited to 1024
select.select([socket], [], [])
else:
Expand Down

0 comments on commit a92a7f2

Please sign in to comment.