Skip to content

Commit 6c0c620

Browse files
committed
parameter fix
1 parent ac5268f commit 6c0c620

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

concurrent_test/D8gerRich.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ def copy_url(task_id: TaskID, url: str, path: str) -> None:
4848

4949
def download(url: str, loop: int, workers: int, dest_dir: str):
5050
"""Download multuple files to the given directory."""
51-
if workers > 4:
52-
workers = 4
53-
if workers < 0:
54-
workers = 2
5551
with progress:
5652
with ThreadPoolExecutor(max_workers=workers) as pool:
5753
for i in range(loop):
@@ -77,7 +73,15 @@ def execute_download():
7773
except Exception as e:
7874
# just log
7975
log.warning("you didn't set any parameters!")
80-
console.print("parameter [bold magenta]loop[/bold magenta] = [bold green]10[/bold green], parameter [bold magenta]workers[/bold magenta] = [bold green]2[/bold green]")
76+
if loop > 64:
77+
workers = 64
78+
if workers < 0:
79+
workers = 10
80+
if workers > 8:
81+
workers = 8
82+
if workers < 0:
83+
workers = 2
84+
console.print("parameter [bold magenta]loop[/bold magenta] = [bold green]{}[/bold green], parameter [bold magenta]workers[/bold magenta] = [bold green]{}[/bold green]".format(loop, workers))
8185
download(url, loop, workers, "./")
8286

8387

0 commit comments

Comments
 (0)