Python 2.7 打印变量时延迟中未处理的错误

Python 2.7 打印变量时延迟中未处理的错误,python-2.7,twisted,Python 2.7,Twisted,我正在尝试运行这行代码: def __init__(self, players, loot): self.players = players self.state = MATCH_STATE_ACTIVE self.pendingShutdown = False self.shutdownTime = 0 self.timer = LoopingCall(self.update(self)) self.timer.start(0.07)

我正在尝试运行这行代码:

    def __init__(self, players, loot):
    self.players = players
    self.state = MATCH_STATE_ACTIVE
    self.pendingShutdown = False
    self.shutdownTime = 0
    self.timer = LoopingCall(self.update(self))
    self.timer.start(0.07)
    self.match_id = 5
    self.playerloot = []
    self.boxloot = []
    self.loot = loot
    print("match [%d]" % self.match_id)
这是在扔垃圾

Unhandled error in deferred
我已经缩小了问题的范围,我知道错误发生在:

print("match [%d]" % self.match_id)

当试图打印任何变量时。错误仅发生在此文件中,因为其他.py文件无法打印变量

该问题是由运行

self.timer = LoopingCall(self.update(self))
self.timer.start(0.07)
太早了,这两行必须放在init的末尾,并在循环调用中删除(self),因此替换为 循环调用(self.update)

def __init__(self, players, loot):
self.players = players
self.state = MATCH_STATE_ACTIVE
self.pendingShutdown = False
self.shutdownTime = 0
self.match_id = 5
self.playerloot = []
self.boxloot = []
self.loot = loot
print("match [%d]" % self.match_id)
self.timer = LoopingCall(self.update)
self.timer.start(0.07)