[issue12463] Calling SocketServer.shutdown() when server_forever() was not called will hang

Марк Коренберг report at bugs.python.org
Tue Aug 9 05:08:43 CEST 2011


Марк Коренберг <socketpair at gmail.com> added the comment:

> Why do you say it "hangs"? It doesn't hang, it just waits for you to
> call serve_forever(): it's not a bug, it's actually a feature.

Okay, for my case, How I should correctly terminate thread?

Conditions:
1. signal may appear at any time
2. thread may become non-alive in any time - either before server_forever (due to exception) or after.

So, after breaking main loop, I should correctly "terminate" thread. I can not say if thread is running. checking isAlive is racy. Even when thread is alive, this is unknown if server_forever was called. Even if serve_forever was not called, we should not rely on calling this ones, because thread may be interrupted by exception before calling serve_forever.

Once again: why not to add patch suggested by Petri Lehtinen ?

----------

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


More information about the Python-bugs-list mailing list