Passing a callable object to Thread

skawaii skawaii at
Sat Feb 16 01:14:50 CET 2008

I'm trying to execute a function in its own thread, due to this method
taking a very long time to complete. I really don't see the need to
inherit the Thread class, as basically every online example shows (at
least the ones I found), nor do I want to. I want to pass the method
into the Thread constructor and let it go wild.

The function I'm trying to execute is in a modulate called tribalwars
and has the following signature:

def populate_all_tribes(data_dir)

Below is the error I'm getting after initializing the thread:

>>> t = th.Thread(target=tribalwars.populate_all_tribes, args=("data/w7/"))
>>> t.start()
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/", line 462, in __bootstrap
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/", line 442, in run
    self.__target(*self.__args, **self.__kwargs)
TypeError: populate_all_tribes() takes exactly 1 argument (8 given)

Can anybody clue me in on what I'm doing wrong? Does my function need
to have a different signature (i.e. *args, **kwargs) in order for this
to work?


More information about the Python-list mailing list