0
我有用于运行一段代码,每30秒蟒一类方法
def hello():
print "hello, world"
t = threading.Timer(30.0, hello)
t.start()
下一个是类,这是我确实想要运行的方法的代码块线程计时器每30秒一次,但我遇到问题。
def continousUpdate(self, contractId):
print 'hello, world new'
t = threading.Timer(30.0, self.continousUpdate, [self, contractId],{})
t.start()
当我运行它,我得到以下错误
pydev debugger: starting
hello, world new
Exception in thread Thread-4:
Traceback (most recent call last):
File "C:\Python27\lib\threading.py", line 552, in __bootstrap_inner
self.run()
File "C:\Python27\lib\threading.py", line 756, in run
self.function(*self.args, **self.kwargs)
TypeError: continousUpdate() takes exactly 2 arguments (3 given)
我也曾尝试
def continousUpdate(self, contractId):
print 'hello, world new'
t = threading.Timer(30.0, self.continousUpdate(contractId))
t.start()
莫名其妙的行为就好像它忽略线程,并给出了一个递归限制错误
是的这个作品,谢谢 – adam 2012-08-06 05:28:56