重载twisted.client.getPage来设置客户端套接字的绑定地址!
在过去的 10 个小时里,我一直在努力实现这一目标:
Translation of myblocking httpclient using standard lib... 变成它的扭曲的非阻塞/异步版本。
10 小时后...通过他们的 API 进行评分——似乎没有人需要做这件事。不错的框架,但似乎......将套接字设置到不同的接口有点难以承受。
任何Python专家都可以阐明这一点和/或引导我走向正确的方向吗?或者我可能错过的任何文档?谢谢!
For the past 10 hours I've been trying to accomplish this:
Translation of my blocking httpclient using standard lib...
Into a twisted nonblocking/async version of it.
10 hours later... scoring through their APIs-- it appears no one has EVER needed to do be able to do that. Nice framework, but seems ...a bit overwhelming to just set a socket to a different interface.
Can any python gurus shed some light on this and/or send me in the right direction? or any docs that I could have missed? THANKS!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,看起来你并没有错过任何事情。 client.getPage不直接支持设置绑定地址。我只是在这里猜测,但我怀疑这是原始开发人员从未想到有人想要指定绑定地址的情况之一。
尽管没有内置支持这样做,但它应该很容易做到。在twisted 中指定传出连接的绑定地址的方法是将绑定地址传递给reactor.connectXXX() 函数。幸运的是,
getPage()
的代码非常简单。我建议三件事:getPage()
的代码及其关联的辅助函数复制到您的项目中Well, it doesn't look like you've missed anything. client.getPage doesn't directly support setting the bind address. I'm just guessing here but I would suspect it's one of those cases where it just never occured to the original developer that someone would want to specify the bind address.
Even though there isn't built-in support for doing this, it should be pretty easy to do. The way you specify binding addresses for outgoing connections in twisted is by passing the bind address to the
reactor.connectXXX()
functions. Fortunately, the code forgetPage()
is really simple. I'd suggest three things:getPage()
and it's associated helper function into your project