using threading module
Victor Muslin
victor at prodigy.net
Fri Jul 14 23:05:02 EDT 2000
I tried using the threading module with the following simple program:
#!/usr/bin/python
from threading import *
reps = 10
def f1(msg='xxx'):
for i in range(0, reps):
print 'f1', msg, i
t1 = Thread(target=f1,args=('bar'))
t1.start()
For some reason it barfs with the following trace that, being rather
new to Python looks pretty nasty to me:
Exception in thread Thread-1:
Traceback (innermost last):
File "E:\Apps\Python_1.5.2\Lib\threading.py", line 376, in __bootstrap
self.run()
File "E:\Apps\Python_1.5.2\Lib\threading.py", line 364, in run
apply(self.__target, self.__args, self.__kwargs)
TypeError: too many arguments; expected 1, got 3
However, when I do not pass the "args" parameter to the Thread constructor, as
in:
t1 = Thread(target=f1)
Yet I've seen example where parameter(s) had been passed like that. What is
going wrong? I am using Python 1.5.2 on Windows NT machine.
TIA
More information about the Python-list
mailing list