Skip to content

Commit eb1837b

Browse files
committed
(core) Limited model download threads to 8 and added minor timeout to prevent issues with Zenodo returning HTTP Error 429: TOO MANY REQUESTS (limit seems to be 56 socket connections per some period)
1 parent a6d033f commit eb1837b

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎pysipfenn/core/pysipfenn.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import gc
44
import csv
55
import json
6-
from time import perf_counter
6+
from time import perf_counter, sleep
77
from typing import List, Union, Dict
88
from importlib.resources import files as resources_files, as_file
99

@@ -264,11 +264,12 @@ def downloadModels(self, network: str = 'all') -> None:
264264
downloadObject = SmartDL(
265265
self.models[net]['URL_ONNX'],
266266
f'{modelPath}/{net}.onnx',
267-
threads=16,
267+
threads=8,
268268
request_args=downloadHeaders
269269
)
270270
downloadObject.start()
271271
print('\nONNX Network Successfully Fetched.')
272+
sleep(1) # Sleep for a second to prevent overwhelming the server with requests
272273
else:
273274
print(f'{net} not detected on disk and no ONNX URL has been provided.')
274275
else:
@@ -284,11 +285,12 @@ def downloadModels(self, network: str = 'all') -> None:
284285
downloadObject = SmartDL(
285286
self.models[network]['URL_ONNX'],
286287
f'{modelPath}/{network}.onnx',
287-
threads=16,
288+
threads=8,
288289
request_args=downloadHeaders
289290
)
290291
downloadObject.start()
291292
print('\nONNX Network Successfully Fetched.')
293+
sleep(1) # Sleep for a second to prevent overwhelming the server with requests
292294
# Not recognized
293295
else:
294296
print('Network name not recognized')

0 commit comments

Comments
 (0)