So, I have a function explain(item) that takes 1 argument. This argument is intended to be a dictionary with 8-9 keys. When I call explain(item)
everything is fine. But when I call (items is the same variable)
threads.append(threading.Thread(target = explain, args=(item)))
threads[i].start()
threads[i].join()
I get errors like this one:
Exception in thread Thread-72:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
TypeError: explain() takes exactly 1 argument (10 given)
What am I doing wrong?
self.__target(*self.__args, **self.__kwargs)
should probably beself.__target(self.__args, self.__kwargs)
. Otherwise you are passing every item in the dictionary as an argument.self.__target
call is coming from the source for the threading module, definitely not where the problem is!