0

I want to use multitasking in a while loop and a for loop in python to make the code faster, I have 300 coins in 50 lists and all the lists in one list.

while True:
     for i in range(len(usdtLists)):
         Thread(target= stopping_volume, args= (usdtLists[i], i)).start()

but I always get this error: unsupported operand type(s) for -: 'NoneType' and 'relativedelta'

Mr. AMI
  • 17
  • 5
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 06 '21 at 21:48

1 Answers1

1

Launching that many threads in parallel may be inefficient and cause errors. You should create a ThreadPoolExecutor (or ProcessPoolExecutor) and submit work to it. For instance you can use the .map(...) method to execute the same function with different arguments from an iterator:

from concurrent.futures import ThreadPoolExecutor

with ThreadPoolExecutor() as e:
  e.map(stopping_volume, usdList, range(len(usdList)))
Louis Lac
  • 5,298
  • 1
  • 21
  • 36