Python 套接字服务器
收到特定消息“退出”后,如何在 SocketServer
中调用 shutdown()
?据我所知,调用 serve_forever()
会阻塞服务器。
谢谢!
How can I call shutdown()
in a SocketServer
after receiving a certain message "exit"? As I know, the call to serve_forever()
will block the server.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用来源,卢克!
摘自 SocketServer.py:
Use the source, Luke!
Excerpt from SocketServer.py:
否,
serve_forever
正在定期检查标志(默认为 0.5 秒)。调用 shutdown 将引发此标志并导致serve_forever结束。No the
serve_forever
is checking a flag on a regular basis (by default 0.5 sec). Calling shutdown will raise this flag and cause the serve_forever to end.