[Twisted-Python] finger tutorial: server slow to shutdown

Brian King free.as.in.speech at gmail.com
Thu Oct 19 04:32:37 EDT 2006


I was working my way through the tutorial, running each version of the
server and testing it out with "telnet localhost 1079".  When I got to
this ( http://twistedmatrix.com/projects/core/documentation/howto/tutorial/intro.html#auto11)
version of the server, I noticed that the server was not shutting down
immediately when I pressed ctrl-c.  The script I'm running is a
verbatim copy of the tutorial code.

I see the following behavior:
1. If immediately after receiving a response from a "finger" query I
press ctrl-c to stop the server, the server shuts down:
    a) after about 20 seconds, if there is no activity on port 1079, or
    b) as soon as a connection is attempted on port 1079 (e.g. "telnet
localhost 1079").
2.  If after having waited some time (e.g. 30 seconds) after the last
query I press ctrl-c to stop the server, it shuts down only after the
next connection attempt on port 1079.
3.  If no connections have been made to the server, ctrl-c shuts it
down immediately.

For the case 1) above:
Running "netstat -tn" after having pressed ctrl-c and before the
server shuts down gives the following output:
Active Internet connections
Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)
tcp4       0      0  127.0.0.1.1079         127.0.0.1.57791        TIME_WAIT
...
(nothing indicating an open connection to the queried web server)

For the case 2) above, there is no mention of port 1079 in the output
from "netstat -tn".

I've spent some time trying to understand why it doesn't shut down
immediately in cases 1 and 2, but haven't figured it out.  Can anybody
shed some light on what is going on?  What would I have to do to get
it to shutdown quickly?

Environment info:
freebsd 6.1 release
python 2.4.3
twisted 2.4.0

Thanks,
Brian




More information about the Twisted-Python mailing list