From 40d3b631837d40a5748e6783726800a676eb73b6 Mon Sep 17 00:00:00 2001 From: Shane Hathaway Date: Thu, 15 Sep 2016 12:50:44 -0600 Subject: [PATCH] Fix compatibility with Twisted 16.4.1 (and possibly earlier versions). Twisted now calls pauseProducing() when it finishes receiving the request. For txsockjs to continue receiving data from the transport, it now needs to call resumeProducing(). This should have no effect on earlier versions of Twisted. --- txsockjs/websockets.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/txsockjs/websockets.py b/txsockjs/websockets.py index f982401..58c3b7e 100644 --- a/txsockjs/websockets.py +++ b/txsockjs/websockets.py @@ -37,6 +37,7 @@ from zope.interface import implementer, Interface +from twisted.internet import interfaces from twisted.protocols.policies import ProtocolWrapper, WrappingFactory from twisted.python import log from twisted.python.constants import NamedConstant, Names @@ -546,6 +547,12 @@ def render(self, request): # transport's lifecycle. transport, request.transport = request.transport, None + # Twisted 16.4.1 calls pauseProducing() once the request is received. + # Resume the producer now. + producer = interfaces.IPushProducer(transport, None) + if producer is not None: + producer.resumeProducing() + # Connect the transport to our factory, and make things go. We need to # do some stupid stuff here; see #3204, which could fix it. if request.isSecure():