带有 mod_wsgi 的 apache 服务器 + python 作为后端,我如何才能通知我的连接状态?
我正在尝试使用 apache 作为 http 服务器,mod_wsgi + python 作为逻辑处理程序来构建一个 Web 服务器,该服务器应该处理长请求而不返回,这意味着我想继续向该请求写入内容。 问题是,当链接断开时,套接字处于 CLOSE_WAIT 状态,apache 不会通知我的 python 程序,这意味着,我必须写一些东西来获取异常,说链接已断开,但这些消息丢失了并且无法恢复。
我尝试在通过 /proc/net/tcp 写入之前获取套接字状态,但它无法阻止快速连接/断开连接。
任何人有任何想法,请帮忙,非常感谢!
i'm trying to build a web server using apache as the http server, mod_wsgi + python as the logic handler, the server was supposed to handler long request without returning, meaning i want to keep writing stuff into this request.
the problem is, when the link is broken, the socket is in a CLOSE_WAIT status, apache will NOT notify my python program, which means, i have to write something to get an exception, says the link is broken, but those messages were lost and can't be restored.
i tried to get the socket status before writing through /proc/net/tcp, but it could not prevent a quick connect/break connection.
anybody has any ideas, please help, very much thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你不能。这是 WSGI 规范定义的 API 的限制。因此,与 Apache 或 mod_wsgi 无关,因为如果您遵循 WSGI 规范,您将在任何 WSGI 服务器上遇到同样的问题。
如果您在 Google 网上论坛上搜索 mod_wsgi 邮件列表,您会发现过去有很多关于此类问题的讨论。
You cant. It is a limitation of the API defined by the WSGI specification. So, nothing to do with Apache or mod_wsgi really as you will have the same issue with any WSGI server if you follow the WSGI specification.
If you search through the mod_wsgi mailing list on Google Groups you will find a number of discussions about this sort of problem in the past.