Repository: docker/docker-py

Issue:
Cannot use docker with eventlet since #2865
Before #2865, it was possible to use docker-py with a eventlet-based project.
However, after the inclusion of a tests for using poll(), i now have errors, see below.

This is expected: eventlet removes poll function on the select module on purpose. See https://github.com/eventlet/eventlet/issues/608#issuecomment-612359458

So instead of checking if the platform is win32, we should check if the select module have a poll method. Which also make it more cross-platform compatible as per select.poll documentation (https://docs.python.org/3/library/select.html#select.poll - Not supported by all operating systems, but not mentionning win32 exactly.)

```
.venv/lib/python3.11/site-packages/docker/utils/socket.py:156: in consume_socket_output                                       [64/1813]
    return bytes().join(frames)                                                                                                        
.venv/lib/python3.11/site-packages/docker/api/client.py:422: in <genexpr>                                                              
    gen = (data for (_, data) in gen)                                                                                                  
.venv/lib/python3.11/site-packages/docker/utils/socket.py:113: in frames_iter_no_tty                                                   
    (stream, n) = next_frame_header(socket)                                                                                            
.venv/lib/python3.11/site-packages/docker/utils/socket.py:85: in next_frame_header                                                     
    data = read_exactly(socket, 8)                                                                                                     
.venv/lib/python3.11/site-packages/docker/utils/socket.py:70: in read_exactly                                                          
    next_data = read(socket, n - len(data))                                                                                            
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _      
                                                                                                                                       
socket = <socket.SocketIO object at 0x7f0f24f04c10>, n = 8                                                                             
                                                                                                                                       
    def read(socket, n=4096):                                                                                                          
        """                                                                                                                            
        Reads at most n bytes from socket                                                                                              
        """                                                                                                                            
                                                                                                                                       
        recoverable_errors = (errno.EINTR, errno.EDEADLK, errno.EWOULDBLOCK)                                                           
                                                                                                                                       
        if not isinstance(socket, NpipeSocket):                                                                                        
            if sys.platform == 'win32':                                                                                                
                # Limited to 1024                                  
                select.select([socket], [], [])                    
            else:                
>               poll = select.poll()                               
E               AttributeError: module 'select' has no attribute 'poll'                                                                

.venv/lib/python3.11/site-packages/docker/utils/socket.py:39: AttributeError   
```


Discussion:

Resolving patch:
diff --git a/docker/utils/socket.py b/docker/utils/socket.py
--- 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:


Test patch: