[Twisted-Python] reactor.addSystemEventTrigger("before", "shutdown", self.logout)
Manlio Perillo
manlio_perillo at libero.it
Fri Apr 14 13:15:25 MDT 2006
Hi.
I would like to have a function be called at the very end of the reactor
lifetime.
I have tried with the statement in the subject, where self.logout sends
a packet via UDP (self is an instance of a class derived from
DatagramProtocol).
But this seems to be not allowed.
I obtain:
Traceback (most recent call last):
File "...\twisted\python\log.py", line 53, in callWithLogger
[...]
--- <exception caught here> ---
File "...\twisted\internet\selectreactor.py", line 139, in doReadOrWrite
why = getattr(selectable, method)()
File "...\twisted\internet\udp.py", line 114, in doRead
data, addr = self.socket.recvfrom(self.maxPacketSize)
exceptions.AttributeError: 'Port' object has no attribute 'socket'
Traceback (most recent call last):
File "justmyscript.py", line 79, in ?
reactor.run()
[...]
--- <exception caught here> ---
File "...\twisted\python\log.py", line 53, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "...\twisted\python\log.py", line 38, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "...\twisted\python\context.py", line 59, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "...\twisted\python\context.py", line 37, in callWithContext
return func(*args,**kw)
File "...\twisted\internet\selectreactor.py", line 149, in doReadOrWrite
self._disconnectSelectable(selectable, why, method=="doRead")
File "...\twisted\internet\posixbase.py", line 256, in _disconnectSelectable
selectable.connectionLost(failure.Failure(why))
File "...\twisted\internet\udp.py", line 207, in connectionLost
self.protocol.doStop()
File "...\twisted\internet\protocol.py", line 490, in doStop
assert self.numPorts > 0
exceptions.AssertionError:
This means, in short, that in a shutdown event I can't use the reactor?
I think that this should be documented.
Thanks and regards Manlio Perillo
More information about the Twisted-Python
mailing list