diff --git a/jsonschema/validators.py b/jsonschema/validators.py index fed56a27e..b94b396c6 100644 --- a/jsonschema/validators.py +++ b/jsonschema/validators.py @@ -793,8 +793,13 @@ def resolve_remote(self, uri): result = requests.get(uri).json() else: # Otherwise, pass off to urllib and assume utf-8 - with urlopen(uri) as url: + url = None + try: + url = urlopen(uri) result = json.loads(url.read().decode("utf-8")) + finally: + if url: + url.close() if self.cache_remote: self.store[uri] = result