thriftpy2
thriftpy2 copied to clipboard
What if I remove the `while True` loop in TThreadedServer?
In TThreadedServer, what if I remove the while True
loop and process just once? The while loop seems to prevent the thread from ending and keeps memory usage growing.
def handle(self, client):
itrans = self.itrans_factory.get_transport(client)
otrans = self.otrans_factory.get_transport(client)
iprot = self.iprot_factory.get_protocol(itrans)
oprot = self.oprot_factory.get_protocol(otrans)
try:
# while True:
self.processor.process(iprot, oprot)
except TTransportException:
pass
except Exception as x:
logger.exception(x)
I think the server will close connect after handle one request if you remove the look.