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

Марк Коренберг report at bugs.python.org
Tue Jul 26 18:25:15 CEST 2011


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

In my case, exception occured in separate thread between the begginig of the thread and starting loop.

Main thread has a code that correctly stops that separate thread. It just calls loop_thread.server.server_close() and after that, calls loop_thread.join()

So, if program termination required, but loop was not started, deadlock occur. Moreover, I can not detect if loop was started. And more more over, if I detect that loop was not started, there is chance, that it may be started a bit later, next after my checking. In that case, either loop will not be terminated correctly (if process exits) or join() may block.

So, please DO NOT ADD detection if loop was started. That will generate race-conditions in user code. I think it's never needed. If one wants to detect that, one may use separate variable:
{code}
started = True
xxx.serve_forever() 
{code}

----------

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


More information about the Python-bugs-list mailing list