Repository navigation
Description
Hello
I was updating the Dask packaging for Debian to Dask 0.17.2 and had test failures during the build in dask/bytes/tests/test_httpy.
E requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8999): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f8be024b160>: Failed to establish a new connection: [Errno 111] Connection refused',))
/usr/lib/python3/dist-packages/requests/adapters.py:508: ConnectionError
During handling of the above exception, another exception occurred:
@pytest.fixture(scope='module')
def dir_server():
with tmpdir() as d:
for fn in files:
with open(os.path.join(d, fn), 'wb') as f:
f.write(b'a' * 10000)
if PY2:
cmd = ['python', '-m', 'SimpleHTTPServer', '8999']
else:
cmd = ['python', '-m', 'http.server', '8999']
p = subprocess.Popen(cmd, cwd=d)
timeout = 10
while True:
try:
requests.get('http://localhost:8999')
break
except requests.exceptions.ConnectionError:
time.sleep(0.1)
timeout -= 0.1
if timeout < 0:
> raise RuntimeError('Server did not appear')
E RuntimeError: Server did not appear
dask/bytes/tests/test_http.py:36: RuntimeError
I'm only building a Python 3 version, and I realized this piece of code in dir_server test_http.py was going to run the wrong version of Python.
if PY2:
cmd = ['python', '-m', 'SimpleHTTPServer', '8999']
else:
cmd = ['python', '-m', 'http.server', '8999']On Debian (and I believe other Linux systems) the system Python 3 interpreter is installed as
/usr/bin/python3, and /usr/bin/python is the Python 2 interpreter.
So because the test is running under Python 3 it uses the Python 3 arguments, but launches the default Python 2 interpreter.
I think it works for you because you're doing most of your testing in conda or a virtualenv where the first python on the path is the expected python version.
My idea to solve the problem robustly is to replace 'python' with sys.executable, which should guarantee that the test HTTP server is running under the same python that the tests are using regardless of the test environment.
I have a pull request, but I thought I should file the issue before making the pull request.
Activity
detrout commentedon Apr 29, 2018
Sigh I reran all the tests in a new environment with my patch... and now I have a new exeception.
Here's the commit, but apparently I need to keep investigating.
detrout@481c339
mrocklin commentedon Apr 29, 2018
I agree that using
sys.executableis preferable and a PR would be welcome.At first glance the exception doesn't mean much to me. @martindurant may have more experience here though.
mrocklin commentedon Apr 29, 2018
As always @detrout thank you for keeping the project up-to-date on Debian. I appreciate it.
martindurant commentedon Apr 29, 2018
403 forbidden?
The server is a simple http server without access controls, so that seems quite weird. It should start a process to serve files from a temp directory created in the main process - might the temp directory be accessible only to the process that made it?
mrocklin commentedon Apr 29, 2018
@detrout I wonder if replacing
localhostwith127.0.0.1would work for you? Sometimes different machines treat localhost differently.detrout commentedon Apr 30, 2018
It looks like I was tired and my test environment wasn't clean enough and the some of the unpatched code was still around. I cleaned, and rebuilt and the tests (for dask) all pass now. (There's still some problems with distributed, but I don't have a good handle on it yet)
mrocklin commentedon Apr 30, 2018
detrout commentedon May 1, 2018
I think this is resolved.