【发布时间】:2012-12-14 22:18:30
【问题描述】:
我正在为 twisted 编写一个自定义反应器,当它必须停止时需要进行一些清洁。 我尝试像这样覆盖停止方法:
def stop(self):
posixbase.PosixReactorBase.stop(self)
#cleanup code here
然而,它似乎不总是被调用。当我像这样python -m cProfile /usr/bin/trial -r custom tests/ | grep "stop" 运行试验时,唯一调用的 stop 方法是:
2 0.000 0.000 0.000 0.000 abstract.py:397(stopReading)
1 0.000 0.000 0.000 0.000 abstract.py:405(stopWriting)
1 0.000 0.000 0.000 0.000 log.py:691(stop)
1 0.000 0.000 0.000 0.000 protocol.py:678(stopProtocol)
3 0.000 0.000 0.000 0.000 reporter.py:97(stopTest)
3 0.000 0.000 0.000 0.000 result.py:79(stopTest)
1 0.000 0.000 0.000 0.000 udp.py:218(stopListening)
【问题讨论】: