[Flask] Flask in debug mode and socket.setdefaulttimeout on Python 2

Jacopo Notarstefano jacopo.notarstefano at gmail.com
Thu Jun 16 18:04:17 EDT 2016


In the past few months our Flask application was randomly returning
EAGAIN errors (error code 11 on Linux or 35 on Mac) on some requests
when developing using DEBUG=True.

A colleague recently found the cause: we were importing a library
which was calling socket.setdefaulttimeout during its initialisation.
See here for a minimal reproduction:
https://github.com/mihaibivol/isbnlib-flask-error-demo, or see the
reproduction on Travis here:
https://travis-ci.org/mihaibivol/isbnlib-flask-error-demo/builds/138128020.

We can work around this bug by using a different library or switching
to Gunicorn for development, so that's not the issue. My purpose for
posting is twofold:

1. Informing the Flask users about this, so that, if they've
intermittently seen this error, they know they should audit their
dependencies for socket.setdefaulttimeout.

2. Notifying the people versed in Flask internals to see if we should
file a Flask issue.

An interesting side note is that this appears to happen only on Python 2.

Cheers,
Jacopo Notarstefano


More information about the Flask mailing list