Sfoglia il codice sorgente

Add timeout for image download

If the image download get stuck
requests.get() will hang forever.

This patch includes a timeout of
30s to avoid this behavior.

This fixes #151.
Alexandre Vicenzi 6 anni fa
parent
commit
2346eb07b5
1 ha cambiato i file con 1 aggiunte e 1 eliminazioni
  1. 1 1
      deoldify/visualize.py

+ 1 - 1
deoldify/visualize.py

@@ -32,7 +32,7 @@ class ModelImageVisualizer():
         return PIL.Image.open(path).convert('RGB')
 
     def _get_image_from_url(self, url:str)->Image:
-        response = requests.get(url)
+        response = requests.get(url, timeout=30)
         img = PIL.Image.open(BytesIO(response.content)).convert('RGB')
         return img