Message141170
| Author |
socketpair |
| Recipients |
giampaolo.rodola, neologix, petri.lehtinen, pitrou, santoso.wijaya, socketpair |
| Date |
2011年07月26日.16:52:20 |
| SpamBayes Score |
0.009647746 |
| Marked as misclassified |
No |
| Message-id |
<1311699141.09.0.915051235446.issue12463@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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) |
|