From 62d5535351833af38ef32945c694c198dda9a5ff Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Thu, 2 Jan 2020 11:58:02 +0200 Subject: [PATCH] Fix requests issue in python 2.7 that can cause a deadlock when importing netrc --- trains/backend_api/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/trains/backend_api/utils.py b/trains/backend_api/utils.py index e8ce392d..ccadd234 100644 --- a/trains/backend_api/utils.py +++ b/trains/backend_api/utils.py @@ -95,6 +95,13 @@ def get_http_session_with_retry( 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: Retry.BACKOFF_MAX = backoff_max