简体   繁体   中英

How to quit a thrift server in Python

I am writing an application in Python that uses thrift to communicate between itself and a client. Whenever I try to exit the application (using Ctrl-C or the exit button on the window), the thrift server keeps the application alive, probably because the server.serve() function enters an infinite loop. What is the best way to exit this server when the rest of the application quits?

It turns out my problem was not actually thrift-specific. I was running an infinite loop in a non-daemonic thread; therefore, python waited for that thread to close before my whole program would close. Setting "self.daemon = True" in the thread's init method fixed the problem nicely.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM