扭曲的传输.write
有没有办法强制 self.transport.write(response) 立即写入其连接,以便下一次调用 self.transport.write(response) 不会缓冲到同一个调用中。
我们有一个客户,其遗留软件无法修改,它读取第一个请求,然后再次开始读取,我遇到的问题是扭曲地将两个写入连接在一起,这打破了客户我尝试过延迟的任何想法,但我不知道我认为在这种情况下不会有帮助
示例:
self.transport.write("|123|") # amount of messages to follow
a loop to generate next message
self.transport.write("|message 1 text here|")
预期:
|123|
|message 1 text here|
结果:
|123||message 1 text here|
Is there any way to force self.transport.write(response) to write immediately to its connection so that the next call to self.transport.write(response) does not get buffered into the same call.
We have a client with legacy software we cannot amend, that reads for the 1st request and then starts reading again, and the problem I have is twisted joins the two writes together which breaks the client any ideas i have tried looking into deferreds but i don't think it will help in this case
Example:
self.transport.write("|123|") # amount of messages to follow
a loop to generate next message
self.transport.write("|message 1 text here|")
Expected:
|123|
|message 1 text here|
Result:
|123||message 1 text here|
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许您可以将协议注册为传输的拉生产者
,然后在协议中创建一个具有作业缓冲的写入方法
数据,直到传输调用协议的resumeProducing方法来获取
数据一一列出。
Maybe You can register your protocol as a pull producer to the transport
and then create a write method in your protocol that has it's job buffering
the data until the transport call your protocol resumeProducing method to fetch
the data one by one.
您能告诉我您使用的是哪种交通工具吗?对于大多数实现来说,
这是典型的方法:
根据详细信息,可以更改写入函数的行为以根据需要进行操作。
Can you tell which transport you are using. For most implementations,
This is the typical approach :
Based on the details the behavior of write function can be changed to do as desired.
我在使用低级 Python 2.6 时遇到了一些相关的问题。与我交谈的主机期待一个 ACK 字符,然后是一个单独的数据缓冲区,它们全部同时出现。在上面
其中,这是一个 TLS 连接。但是,如果您直接引用套接字,则可以调用
sendall() as:
to:
... 这应该有效。这在 X86 上使用 Twisted 的 Python 2.7 上似乎不是问题,只是
SHEEVAPlug ARM 处理器上的 Python 2.6。
I was having a somewhat related problem using down level Python 2.6. The host I was talking to was expecting a single ACK character, and THEN a separate data buffer, and they all came at once. On top
of this, it was a TLS connection. However, if you reference the socket DIRECTLY, you can invoke a
sendall() as:
to:
... and that should work. This does not seem to be a problem on Python 2.7 with Twisted on X86, just
Python 2.6 on a SHEEVAPlug ARM processor.