Преглед изворни кода

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 година
родитељ
комит
2346eb07b5
1 измењених фајлова са 1 додато и 1 уклоњено
  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