diff --git a/py/selenium/webdriver/remote/remote_connection.py b/py/selenium/webdriver/remote/remote_connection.py index 58804e462fc66..ac9e0e6b4a835 100644 --- a/py/selenium/webdriver/remote/remote_connection.py +++ b/py/selenium/webdriver/remote/remote_connection.py @@ -371,8 +371,8 @@ def _request(self, method, url, body=None): statuscode = resp.status else: - http = urllib3.PoolManager(timeout=self._timeout) - resp = http.request(method, url, body=body, headers=headers) + with urllib3.PoolManager(timeout=self._timeout) as http: + resp = http.request(method, url, body=body, headers=headers) statuscode = resp.status if not hasattr(resp, 'getheader'):