Fix requests issue in python 2.7 that can cause a deadlock when importing netrc

This commit is contained in:
allegroai 2020-01-02 11:58:02 +02:00
parent f4be527a21
commit 62d5535351

View File

@ -95,6 +95,13 @@ def get_http_session_with_retry(
session = requests.Session() session = requests.Session()
# HACK: with python 2.7 there is a potential race condition that can cause
# a deadlock when importing "netrc", inside the get_netrc_auth() function
# setting 'session.trust_env' to False will make sure the `get_netrc_auth()` is not called
# see details: https://github.com/psf/requests/issues/2925
if six.PY2:
session.trust_env = False
if backoff_max is not None: if backoff_max is not None:
Retry.BACKOFF_MAX = backoff_max Retry.BACKOFF_MAX = backoff_max