File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree 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,18 +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
3629 for _ in range (threads ):
3730 new_task ()
3831
39- while tasks : # While there are tasks pending
40- # Wait for the first task to complete
4132 while tasks :
4233 done , pending = await asyncio .wait (tasks , return_when = asyncio .FIRST_COMPLETED )
4334 for task in done :
4435 arg = tasks .pop (task )
45- result = task .result ()
46- 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 ())
4742 new_task ()
4843 except (KeyboardInterrupt , asyncio .CancelledError ):
4944 for task in tasks :
@@ -76,7 +71,6 @@ def validate_urls(urls):
7671 for url in urls :
7772 parsed_url = urlparse (url )
7873 if (not parsed_url .netloc ) or (parsed_url .scheme not in ["http" , "https" ]):
79- if not parsed_url .netloc or parsed_url .scheme not in ["http" , "https" ]:
8074 log .warning (f"skipping invalid URL: { url } " )
8175 continue
8276 yield url
You can’t perform that action at this time.
0 commit comments