thriftpy2 icon indicating copy to clipboard operation
thriftpy2 copied to clipboard

What if I remove the `while True` loop in TThreadedServer?

Open wangheda opened this issue 2 years ago • 1 comments

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)

wangheda avatar Apr 14 '22 12:04 wangheda

I think the server will close connect after handle one request if you remove the look.

aisk avatar Apr 14 '22 14:04 aisk