-
Notifications
You must be signed in to change notification settings - Fork 25
Python 3.5 Support #34
base: master
Are you sure you want to change the base?
Conversation
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.
…prepare input for JSON encoding, where the input may be an already encoded JSON message.
…2.99 to suggest 1.3 should be the next version number.
I took this PR to try it out. I found that this seems to work not quite fully with how Twisted handles Python 3 connections (or at least txsockjs is passing things in a way that's incompatible with how Twisted passes things through normally). Here's my situation:
I'll keep looking at this and maybe try to fix it, though I've only done minimal prodding on txsockjs so far. I'll keep looking here, too, in case you get it before me. |
Thanks for trying out the patch. I've been using the web socket protocol
for months without issues, but it's possible the other protocols need work.
I guess you're using the JSON protocol. Note that the protocol stack is a
little strange: sometimes we have to intentionally embed JSON in JSON.
Good luck! It would certainly be good to get all the protocols ported to
Python 3.
…On Nov 1, 2017 10:15 PM, "ElementalAlchemist" ***@***.***> wrote:
I took this PR to try it out. I found that this seems to work not quite
fully with how Twisted handles Python 3 connections (or at least txsockjs
is passing things in a way that's incompatible with how Twisted passes
things through normally).
Here's my situation:
- Using txsockjs as an endpoint
- Someone connects using it (over the websocket protocol) and sends a
message to the server
- Twisted passes the message off to txsockjs to handle
- txsockjs gets hit right in the JsonProtocol.dataReceived
- dataReceived passes the parsed data (from the JSON parser) to
normalize
- The normalized data (which is str, not bytes), gets passed into
the protocol's dataReceived
- Twisted passes this str (not bytes) right through to my protocol
handler's dataReceived, through which it receives bytes (not str)
messages normally over non-sockjs connections (as an endpoint specified
with just a "tcp:" or "ssl:" prefix to serverFromString as opposed to
the "sockjs:" prefix).
I'll keep looking at this and maybe try to fix it, though I've only done
minimal prodding on txsockjs so far, so I'm not sure how I actually feel
about trying to do it right in normalize.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#34 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAm7bv_fsZZj8TpkhnTU4Du3XDBh1-Nzks5syUHLgaJpZM4KNHi_>
.
|
Update: I fixed this for myself by adding a new line that does the encoding to bytes right before line 88 of txsockjs/protocols/websocket.py. Thanks for your work getting most of this ported! :) |
I took a look today and I agree it needs fixing. Now I'm wondering why it's working on my side. I'm going to investigate. |
…ded bytes (in Python 2 as well). Also added a test server (echotest.py) that works with the sockjs-protocol test suite. The suite revealed some issues, now fixed.
…d for re-encoding received messages.
I added I decided it's probably best for dataReceived() to receive a UTF-8 encoded string so that Twisted protocol composition can work as expected. I also added support for a stringReceived() protocol method so consumers can skip the UTF-8 encoding. |
This branch makes txsockjs compatible with Python 3.5 while retaining compatibility with Python 2.7. All qunit tests pass. Note that I added a dependency on the "six" package.