Using Pyro together with Jython
In the past, there used to be some comments on this page about problems in Jything that prevented Pyro to work with it at all, but a lot has been changed since then (Jython has been updated a lot, Pyro and Python itself have seen updates too). I invite you to post about your experiences with using Pyro in Jython below (or on the mailing list as usual). I will try to organise this page now and then to reflect the current known status of using Pyro in Jython.
For starters: Setting it up to use Pyro in Jython: /SettingUp
Note: you need Jython 2.5, and Pyro 3.8 or newer. Older versions are not supported.
Current status
There are a few issues:
the timeout feature (setTimeout()) causes unreliable behavior so it may not be used from Jython code
- problems with select()
- jython server aborts with connection reset on Mac OS X.
- strange problem when using poll: it keeps on triggering.
- jython udp broadcast socket gets address wrong when using timeout
See below.
1. timeout feature causes unreliable behavior
When using Pyro's timeout feature (setTimeout() call) you trigger unreliable behavior in Jython. So this feature may not be used from Jython code. It will throw a RuntimeException.
The exact problem is that enabling timeouts triggers the use of select(), and that is at this time not yet very stable in Jython. You will get the select() errors mentioned in the following section. must provide some sample code and stacktrace to be able to debug
2. problems with select()
Sometimes you get crashes like this:
File "E:\jython\Lib\select.py", line 59, in __init__
self.selector = java.nio.channels.Selector.open()
java.io.IOException: java.io.IOException: Unable to establish loopback connection
analysis / solution
It seems there is a problem with using select() in jython in threads and/or on client sockets. I have made an issue in Jython's bug tracker about this: issue 1291
In any case, Pyro 3.9 contains a fix in the socket code that removes the select() call that caused these issues. Hopefully the problem gets fixed in Jython itself as well but use Pyro 3.9 if you need to get it working without error now or on older jython versions.
3. connection reset error on Mac OS X
Currently a Pyro server running with Jython on Mac OS X will not work correctly because it will cause connection reset errors. Pyro clients are fine. Also, the error doesn't occur on Windows. I don't yet know what is causing this but I'll try to fix it.
4. problem using poll
There seem to be some strange problems using the poll function from the select module in Jython. Once the first connection has been made, the server socket will forever trigger the poll function even if there's no new connection available. The accept() call that is done will fail. This problem does not occur on Mac OS X. (and Windows uses select). Pyro 3 doesn't contain this yet but it occurs in the Pyro 4 code that I'm developing.
5. jython udp broadcast socket gets address wrong when using timeout
It seems that sock.recvfrom() always returns (None,-1) as address, when you're using timeouts. So Pyro won't enable a timeout setting on the broadcast server that's part of the name server, when running on Jython.
