开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜