jython

342 views
Skip to first unread message

Justin C

unread,
May 11, 2012, 12:33:37 PM5/11/12
to python-...@googlegroups.com
All-

I have the start of a very naive jython port of tornado.  Only a few lines of changes/additions were required.

I was wondering:
-How I should test to make sure I haven't broken anything?
-If anyone was interested.

I wouldn't recommend something like this for production use.

Best,
-Justin

Ben Darnell

unread,
May 12, 2012, 1:44:38 PM5/12/12
to python-...@googlegroups.com
On testing: Tornado's test suite is fairly comprehensive and can be
run with "python -m tornado.test.runtests". I also use tox to
automate running the tests with different python versions and
configurations, although it can take some setup work to get everything
installed.

A while back I also got interested in jython and got tornado more or
less working on it. I was interested mainly because I wanted to
experiment with the performance of threads on a GIL-free version of
python, so I abandoned it when I saw how much slower jython was than
cpython in a single thread. I've dusted off my changes and pushed the
generic parts to master
(https://github.com/facebook/tornado/commit/d79458151c6992a1b8258f056e574dade2cc62ac)
and the jython-specific parts to my fork
(https://github.com/bdarnell/tornado/commit/25ed11327ca948c7c31b586679bf219a5df92cb7).

For the curious, I've also tried ironpython and it looks like it would
be much harder to get tornado to work there because it mixes up
aspects of str/bytes/unicode semantics (for example,
u"".encode("utf8") returns unicode, not bytes).

-Ben

Oscar

unread,
May 24, 2012, 5:12:06 PM5/24/12
to python-...@googlegroups.com
Thanks for those changes.  I am also trying to get tornado to work under Jython.  One note, in your change to httpserver.py HTTPConnection:__init(), where you get deal with the assertion resulting from self.stream.socket not having the family attribute, rather than set address to ('0.0.0.0',0) (which makes the interpreter happy but does not result in working code) if you just use the address that was passed in (e.g. self.address = address) or set it to self.stream.socket.getpeername() then the code will actually work.  I have tested this on both Mac and Linux.  The getpeername() is not the best route though, when run in a vm with NAT networking that call gave me the ip of the inet gateway/router not the client.  The "self.address = address" worked fine with both bridged and NAT networking.

Ben Darnell

unread,
May 25, 2012, 12:16:12 AM5/25/12
to python-...@googlegroups.com
Good point. If the family attribute is missing it's reasonable to
assume it's IP instead of something unknown. More to the point, this
check is probably happening at the wrong level:
HTTPConnection.address should always be the remote socket address that
comes from accept(), and we shouldn't mess with it until we're trying
to set HTTPRequest.remote_ip (which is the only part where we really
care about IP-style addressing)

This is also kind of moot because the latest jython betas (2.5.3b1)
fix the missing `family` attribute.

-Ben

Oscar Steele

unread,
May 25, 2012, 1:13:09 PM5/25/12
to python-...@googlegroups.com, python-...@googlegroups.com
Actually 2.5.3b1 still gets the assertion due to the missing 'family' attribute for me (only tested on Linux).

- Oscar

Sent from my iPad
Reply all
Reply to author
Forward
0 new messages