How to stop a SocketServer?

Daniel Fackrell dfackrell at DELETETHIS.linuxmail.org
Mon Jun 24 14:50:52 EDT 2002


"Peter Hansen" <peter at engcorp.com> wrote in message
news:3D1757DF.776A428F at engcorp.com...
> Daniel Fackrell wrote:
> >
> > I faced this problem with a simple chat server I wrote.  I expected that
> > termination of the server with <ctrl-C> should have stopped it
immediately,
> > but it instead waits until some communication is received from each
thread
> > that was stopped at a read().
> >
> > It appears that the current threading implementation does not provide
for
> > termination of threads inside a single python statement (such as a
> > filelike.read()), so I am considering a move to character I/O, checking
to
> > verify that a character is available before each read.
>
> The proper solution to this kind of problem is to use timeouts
> and select.  There's generally no need to check for the data
> being available ahead of time by _polling_, which is inefficient.
>
> -Peter

Any chance I could see a very simple example of this in action?  That would
help my little project out quite a bit.

Would this be something that would allow me to guarantee that the all
threads of the server terminated within, say, five seconds of the server
shutdown request?

--
Daniel Fackrell (dfackrell at linuxmail.org)
When we attempt the impossible, we can experience true growth.





More information about the Python-list mailing list