File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -125,10 +125,8 @@ async def screenshot(self, url):
125125 return tab .webscreenshot
126126 except asyncio .TimeoutError :
127127 self .log .info (f"URL { url } load timed out after { self .timeout } seconds" )
128- raise
129128 except Exception as e :
130129 self .log .error (f"Error visiting { url } : { e } " )
131- raise
132130 finally :
133131 with suppress (Exception ):
134132 await tab .close ()
Original file line number Diff line number Diff line change 1- import io
21import re
3- import sys
4- import time
5- import httpx
6- import shutil
72import asyncio
8- import inspect
93import logging
10- import zipfile
4+ import traceback
115from pathlib import Path
126from contextlib import suppress
137from urllib .parse import urlparse
@@ -32,16 +26,19 @@ def new_task():
3226 task = asyncio .create_task (fn (arg , ** global_kwargs ))
3327 tasks [task ] = arg
3428
35- for _ in range (threads ): # Start initial batch of tasks
29+ for _ in range (threads ):
3630 new_task ()
3731
38- while tasks : # While there are tasks pending
39- # Wait for the first task to complete
32+ while tasks :
4033 done , pending = await asyncio .wait (tasks , return_when = asyncio .FIRST_COMPLETED )
4134 for task in done :
4235 arg = tasks .pop (task )
43- result = task .result ()
44- yield arg , result
36+ try :
37+ result = task .result ()
38+ yield arg , result
39+ except Exception as e :
40+ log .error (f"Error in task { arg } : { e } " )
41+ log .debug (traceback .format_exc ())
4542 new_task ()
4643 except (KeyboardInterrupt , asyncio .CancelledError ):
4744 for task in tasks :
@@ -224,6 +221,16 @@ def truncate_filename(file_path, max_length=255):
224221
225222
226223def color_status_code (status_code ):
224+ """
225+ This function takes an HTTP status code as input and returns it in bold with a specific color based on the first digit of the status code.
226+
227+ Args:
228+ status_code (int or str): An HTTP status code represented as either an integer or string.
229+
230+ Returns:
231+ str: A colored string representation of the status code, indicating its severity level.
232+
233+ """
227234 status_code = str (status_code )
228235 if status_code == "404" :
229236 color = "orchid"
You can’t perform that action at this time.
0 commit comments