I'm writing a custom reactor for twisted and it needs some cleaning to do when it has to stop. I tried overriding the stop method like this:
def stop(self):
posixbase.PosixReactorBase.stop(self)
#cleanup code here
It does, however, seem to not always be called. When I run trial like this python -m cProfile /usr/bin/trial -r custom tests/ | grep "stop"
the only stop methods that are called are:
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)