是否有任何方法强制self.transport.write(response)立即写入其连接,以便下一次调用self.transport.write(response)不会被缓存到同一个调用中。Twisted transport.write
我们有一个客户端,使用我们无法修改的遗留软件,读取第一个请求,然后再次开始阅读,我遇到的问题是扭曲,将两个写入打到一起,打破了客户端的任何想法, deferreds但我不认为它会在这种情况下帮助
例子:
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|
嗨,我知道这是一个旧帖子,但你能告诉我你做了什么来解决这个问题吗? – 2012-04-09 06:24:43
对于它的价值,无法完全可靠地完成这项工作。有一天,你可能会购买一些不同的交换机或路由硬件,并且你的应用会中断。这个扭曲的常见问题解答试图解释:http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#Whyisprotocol.dataReceivedcalledwithwithlylypartatahedataataIdledportport.writewith – Glyph 2013-07-22 21:33:55