[Twisted-Python] Write into a persistent connection before stopping

Boeuf, Jean-Francois jean-francois.boeuf at eads.com
Fri Jan 16 05:33:31 MST 2009


 
Hello,

I have an application using twisted in which the web browser opens a
persistent connection when a user logs in (COMET model). I want to write
data into active persistent connections at server stop to notify client to
logout properly.

To do that, I add a system event trigger to the reactor calling the method
that closes session before shutdown when I start the webService. This method
is called when twisted receives a SIGTERM and I can see in twistd.log traces
of writing to the persistent connexion before services stops and connexions
are closed. But the web browser never receives this content and listening
the traffic between server and client with wireshark, I can't see anything
else than the [FIN, ACK] packets that are sent when server ends all
connections (delayed for maximum clarity in the logs).

The same method is called to logout client properly when session expires and
does work fully.

You can see below the twistd.log file when the servers stops.

Thank you for your help.

Regards

Jean-François


twistd.log
----------
2009-01-16 13:26:16+0100 [-] Received SIGTERM, shutting down.
2009-01-16 13:26:16+0100 [-] 10.37.68.212 - - [16/Jan/2009:12:26:16 +0000]
"GET /sim/listen?sourceScreen=216 HTTP/1.1" 200 166
"http://peyo:8080/sim?id=216" "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr;
rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16"
2009-01-16 13:26:16+0100 [-] 10.37.68.212 - - [16/Jan/2009:12:26:16 +0000]
"GET /sim/listen?sourceScreen=217 HTTP/1.1" 200 166
"http://peyo:8080/sim?id=217" "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr;
rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16"
2009-01-16 13:26:16+0100 [-] 10.37.68.212 - - [16/Jan/2009:12:26:16 +0000]
"GET /sim/listen?sourceScreen=218 HTTP/1.1" 200 166
"http://peyo:8080/sim?id=218&screen0=216&screen1=217&nbScreen=2"
"Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.16) Gecko/20080702
Firefox/2.0.0.16"
2009-01-16 13:26:25+0100 [-] (Port 8080 Closed)
2009-01-16 13:26:25+0100 [-] Stopping factory
<cockpitServer.userSessionManagement.cockpitSite.CockpitSite object at
0xb6db9e6c>
2009-01-16 13:26:25+0100 [-] (Port 8082 Closed)
2009-01-16 13:26:25+0100 [-] Stopping factory
<cockpitServer.soapService.SoapSite object at 0xb7092d0c>
2009-01-16 13:26:25+0100 [-] Main loop terminated.
2009-01-16 13:26:25+0100 [-] Server Shut Down




More information about the Twisted-Python mailing list