[issue12463] Calling SocketServer.shutdown() when server_forever() was not called will hang
Марк Коренберг
report at bugs.python.org
Tue Jul 26 18:52:21 CEST 2011
Марк Коренберг <socketpair at gmail.com> added the comment:
class ThreadedRPC(Thread, SimpleXMLRPCServer):
def __init__(self):
Thread.__init__(self)
SimpleXMLRPCServer.__init__(self)
# python bug workaround, which eliminate hang on test_exception
self._BaseServer__is_shut_down.set()
self.daemon = True
def run(self):
raise Exception('race-condition!')
self.serve_forever()
def main():
rpc = ThreadedRPC(RPC_LISTEN_ADDR, allow_none=True)
rpc.start() # from Thread
# term set by signal handler
while rpc.isAlive() and not term:
time.sleep(0.5)
# note, thread may die in any time! regardles of isAlive()
# if thread dead before calling serve_forever(), will hang here without a workaround
rpc.shutdown() # from xmlrpcservr.
rpc.join() # from thread (no problem, as thread is not Alive)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12463>
_______________________________________
More information about the Python-bugs-list
mailing list