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