Skip to content

Commit

Permalink
Turn clients threads default to be daemon, so the server closes after…
Browse files Browse the repository at this point in the history
… a KeyboardInterrypt
AllanDaemon committed Jun 6, 2016
1 parent 6a4b118 commit 0944247
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions thriftpy/server.py
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ class TThreadedServer(TServer):
"""Threaded server that spawns a new thread per each connection."""

def __init__(self, *args, **kwargs):
self.daemon = kwargs.pop("daemon", False)
self.daemon = kwargs.pop("daemon", True)
TServer.__init__(self, *args, **kwargs)
self.closed = False

@@ -91,7 +91,7 @@ def handle(self, client):
iprot = self.iprot_factory.get_protocol(itrans)
oprot = self.oprot_factory.get_protocol(otrans)
try:
while True:
while not self.closed:
self.processor.process(iprot, oprot)
except TTransportException:
pass

0 comments on commit 0944247

Please sign in to comment.