Thriftpy / thriftpy2

Pure python approach of Apache Thrift.
MIT License
572 stars 91 forks source link

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

Closed wangheda closed 6 months ago

wangheda commented 2 years ago

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)
aisk commented 2 years ago

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