I'm trying to get information from a webservice which provides ~300 endpoints every 5 seconds, but each endpoint call take ~0.5sec
The issue is I'm falling behind the webservice since it take more time to handle every call than generating new ones.
I created threaded function with threading module and it works, but there is a limitation on simultaneous calls on the webservices.
Is there a way to limit threading to for example 10?
def print_blocks(blocks):
for block in blocks: <-- each block is generated every 5 sec
for tsx in block["transactions"]: <-- each block contains ~300 transactions/webservices calls
try:
# print_tsx is a function with the webservice call and print the needed values
threading.Thread(target=print_tsx, args=(tsx["hash"],)).start()