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'

1
  • 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. Commented Oct 6, 2021 at 21:48

1 Answer 1

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)))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.