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'
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)))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.