I am trying multithreading for the first time in Python. I see documentation here. Following is my sample code
from multiprocessing.dummy import Pool as ThreadPool
pool = ThreadPool(4)
mylist = [3,4,5,6,7,8, ..., 5]
results = pool.map(my_method, my_list) # from docs it is clear that pool.map takes method and argument as a list
def my_method(mylist):
data = []
for i in range (len(mylist)):
# do something using mylist = subdata
data.append(subdata)
return data
It returns the following error
Traceback (most recent call last):
File "C:/Users/algorithm.py", line 30, in my_method
for i in range (len(mylist)):
TypeError: object of type 'float' has no len()
From the documentation it is clear that pool.map
takes function and a list (see this tutorial too) but why it is assuming my_list
as a float
giving this error. Any suggestions ? Thanks