Twisted:如何破坏连接?

发布于 2024-12-18 18:35:48 字数 344 浏览 7 评论 0原文

我保留了一个客户端连接列表,其设置如下:

cons = {}
sid = 5
cons[sid] = self.reactor.connectTCP(host, port, myprotocol)

如果该项目仍然连接,并且我调用 del cons[5] ,则连接对象仍然存在。我可以在服务器控制台中看到输出。不过,这个对象肯定已经从字典中消失了。

我可以对其调用 .disconnect() ,然后调用 del cons[5] ,它会断开连接并删除该项目,但我担心该连接仍然存在于某处。

破坏这些连接之一的正确方法是什么?

I keep a list of client connections which are setup like this:

cons = {}
sid = 5
cons[sid] = self.reactor.connectTCP(host, port, myprotocol)

If the item is still connected, and I call del cons[5] , the connection object still persists. I can see the output in my server console. The object is definitely gone from the dict though.

I can call .disconnect() on it, and then call del cons[5] , and it does disconnect and remove the item, but I'm concerned that the connection still exists somewhere.

What would be the proper way to destroy one of these connections?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文