New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Socket timeout in python2 #2425
Comments
See #2300 I'd recommend switching to Python 3 if possible. Python 2 is reaching EOL in a few months, and it doesn't make a lot of sense for us to keep investing in supporting older versions of Python. Alternatively, you can use the binary builds of Compose which are already compiled with Python 3.7. |
Thanks you @shin- for the response. Switching to python3 does seem to fix this problem. I looked the failed test in #2300. I'm no expert but I don't think closing the socket in a different thread is a good idea. I wrote this snippet for testing: from __future__ import print_function
import socket
import threading
import select
import functools
sock = socket.socket()
sock.connect(('127.0.0.1', 8765))
def close_socket(sock):
sock.shutdown(socket.SHUT_RDWR)
sock.close()
print('socket closed in thread')
threading.Timer(3, functools.partial(close_socket, sock)).start()
print('calling select')
select.select([sock], [], [])
print('select returned, calling recv')
data = sock.recv(4096)
print(data, 'end') This blocks forever in You may wonder why the test passes with the Again, I agree that with python2 reaching its EOL it doesn't make sense to fix non-critical bugs like this. Posted the information above just as an FYI. |
Description:
I use docker-compose to start 3 containers, one of them being a web server. The web server
prints some debug info to stdout when processing requests.
I was on a very old docker-py version (2.2.1) but it has been working fine. I recently upgraded to docker-py 3.7.3 and realized that docker-compose is not printing anything if the web server has been idle for a while. Tried to find a threshold of idle time and it's about 60 seconds.
I went on and tried multiple docker-py versions. The latest version that works fine is 3.1.4. I looked the diff between version 3.2.0 and 3.1.4, and found this:
(line 25 in docker/utils/socket.py in 284c3d9)
Looks like it's not doing the
select.select
in python2, hence the socket times out after 60 seconds inread()
.I switched to 3.2.0, removed the condition for
six.PY3
and it works perfectly fine.So my question is: is there a reason why docker-py only do the
select.select
call in python3? If there's a good reason we can't do it python2, is there anything a docker-compose user can do to avoid socket timeout? Should that be a docker-compose issue?(This docker-compose issue may be related docker/compose#6261)
The text was updated successfully, but these errors were encountered: