[New-bugs-announce] [issue13749] socketserver can't stop

K Richard Pixley report at bugs.python.org
Mon Jan 9 20:19:29 CET 2012


New submission from K Richard Pixley <rich at noir.com>:

Once I've instantiated my server class, along with a handler class, called server.serve_forever(), handler.handle() has been called, I've done my work, and I'm ready to shut the whole thing down...

How do I do that?

The doc says server.shutdown(), but if I call self.server.shutdown() from within handler.handle(), I seem to get a deadlock, which is exactly what I'd expect in a single threaded system with no way to "signal" the server.server_forever() loop which is several frames up the stack.

I've also tried sys.exit() but it seems that the server object is catching that as an exception.

How is this expected to work?  How do I terminate the server.serve_forever() loop?

Both 3.2 and 2.7 appear to behave the same way.  The documentation is confusing here as it doesn't explain what is expected to happen in this case.

----------
components: Library (Lib)
messages: 150965
nosy: teamnoir
priority: normal
severity: normal
status: open
title: socketserver can't stop
type: behavior
versions: Python 2.7, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13749>
_______________________________________


More information about the New-bugs-announce mailing list