Search code examples
pythonconcurrencygevent

`NewConnectionError` while using gevent pool


While trying to use gevent to parallelize IO bound work, I'm getting a ton of these error messages:

requests.exceptions.ConnectionError: HTTPConnectionPool(host='blabla.com', port=80): Max retries exceeded with url: /bla (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 16] Device or resource busy'))

My code looks uses a utils such as this:

def run_parallel(f, it):
    return pool.Group().map(f, it)

What is the correct way to avoid these errors?


Solution

  • Apparently I was missing the monkey-patching part.

    from gevent import monkey
    monkey.patch_all()