[Twisted-Python] Clean shutdown of an XMLStream session
Ralph Meijer
twisted at ralphm.ik.nu
Wed Jun 15 05:51:53 EDT 2005
On Wed, Jun 15, 2005 at 12:28:17PM +1000, Steve Smith wrote:
> Hi,
>
> This is probably a stupid question, but what is method of cleanly
> shutting down an XMLStream (such that it sends the terminating </stream>
> and closes the connection).
The cleanest way to end a connection is closing the 'XML document'.
Assuming xs is the object holding your XMLStream instance, simply do:
xs.send('</stream:stream>')
This signals to the other party that you want to end the conversation.
The peer will send you the same thing, and the connection will be
shutdown nicely. The STREAM_END_EVENT will be fired, so you can add an
observer to that.
--
Groetjes,
ralphm
More information about the Twisted-Python
mailing list