【发布时间】:2013-12-29 14:58:40
【问题描述】:
我收到以下错误
错误:
tt.start()
TypeError: 'int' object is not callable
我将 threading.Thread 子类化为简单地跟踪时间,当经过的时间与传入的任意值匹配时,它会将匹配键的值从输入字典添加到队列中。另一个线程将定期检查队列以查找工作并在找到时进行处理。
这是引发错误的代码:
class TimerQueue(threading.Thread):
def __init__(self, qyoo, kwargs):
threading.Thread.__init__(self)
self.queue = qyoo
self.work = kwargs
self.start = ceiling(time.time())
self.times = kwargs.keys()
def run(self):
while True:
for t in self.times:
if ceiling(time.time()) - self.start == t:
logger.debug("adding {} to the queue".format(self.work[t]))
self.queue.put(self.work[t])
time.sleep(1)
if __name__ == "__main__":
input_queue = queue.Queue()
tt = TimerQueue(input_queue, time_url_dict)
tt.start()
为什么我在调用 start 时收到错误消息?这是在运行 Windows 7 的 Python 3.3.3 中。
【问题讨论】:
标签: python windows multithreading python-3.x python-3.3