Skip to content

Instantly share code, notes, and snippets.

@paolodina
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paolodina/f2cbf7b1c7cee2756b05 to your computer and use it in GitHub Desktop.
Save paolodina/f2cbf7b1c7cee2756b05 to your computer and use it in GitHub Desktop.
execnet jython 2.7b3 (default:9fef5da411e5)
Update:
relevant discussion on IRC [21:13]
http://www.extreme.st/jython.extreme.st/irclogs/index.php/?date=2014-09-30
# test2.py
import execnet
gw = execnet.makegateway("popen//python=/path/to/jython")
gw.remote_exec("""
from org.example.query import QueryManager
m = QueryManager()
res = m.get_list()
# ^-- return ArrayList of custom type instances
# ************************************************************
# !!! but it hangs forever !!!
# ************************************************************
# this is never sent back
channel.send(res2list(res)) # get a list using a fictitious function
""")
print ch1.receive()
$ python test2.py
[5626] gw0 [receiver-thread] RECEIVERTHREAD: starting to run
[5626] gw0 sent <Message CHANNEL_EXEC channel=1 lendata=145>
[5629] creating slavegateway on <execnet.gateway_base.Popen2IO instance at 0x2>
[5629] gw0-slave [serve] spawning receiver thread
[5629] gw0-slave [serve] integrating as primary thread
[5629] gw0-slave [receiver-thread] RECEIVERTHREAD: starting to run
[5629] gw0-slave [receiver-thread] received <Message CHANNEL_EXEC channel=1 lendata=145>
[5629] gw0-slave execution starts[1]: '\nfrom org.example.query impo
[5629] gw0-slave sent <Message CHANNEL_DATA channel=1 lendata=39>
[5629] gw0-slave execution finished
[5629] gw0-slave sent <Message CHANNEL_CLOSE channel=1 lendata=0>
[5629] gw0-slave 1 sent channel close message
# ....... hangs forever
The function terminates when m.get_list() is commented. In this case the result is [1, 2, 3]
as expected, but there an EOFError is raised. Any idea what the problem could be?
[5903] gw0 [receiver-thread] RECEIVERTHREAD: starting to run
[5903] gw0 sent <Message CHANNEL_EXEC channel=1 lendata=146>
[5906] creating slavegateway on <execnet.gateway_base.Popen2IO instance at 0x2>
[5906] gw0-slave [serve] spawning receiver thread
[5906] gw0-slave [serve] integrating as primary thread
[5906] gw0-slave [receiver-thread] RECEIVERTHREAD: starting to run
[5906] gw0-slave [receiver-thread] received <Message CHANNEL_EXEC channel=1 lendata=146>
[5906] gw0-slave execution starts[1]: '\nfrom org.example.query impo
[5903] gw0 [receiver-thread] received <Message CHANNEL_DATA channel=1 lendata=39>
[5906] gw0-slave sent <Message CHANNEL_DATA channel=1 lendata=39>
[1, 2, 3]
[5906] gw0-slave execution finished
[5903] gw0 [receiver-thread] received <Message CHANNEL_CLOSE channel=1 lendata=0>
Traceback (most recent call last):
File "test_2.py", line 32, in <module>
[5906] gw0-slave sent <Message CHANNEL_CLOSE channel=1 lendata=0>
print ch1.receive()
File "/home/paolo/tmp/execnet_py_jy/local/lib/python2.7/site-packages/execnet/gateway_base.py", line 701, in receive
raise self._getremoteerror() or EOFError()
EOFError
[5906] gw0-slave 1 sent channel close message
[5903] === atexit cleanup <Group ['gw0']> ===
[5903] gw0 gateway.exit() called
[5903] gw0 --> sending GATEWAY_TERMINATE
[5903] gw0 sent <Message GATEWAY_TERMINATE channel=0 lendata=0>
[5903] gw0 --> io.close_write
[5903] gw0 waiting for receiver thread to finish
[5906] gw0-slave [receiver-thread] received <Message GATEWAY_TERMINATE channel=0 lendata=0>
[5906] gw0-slave [receiver-thread] finishing receiving thread
[5906] gw0-slave [receiver-thread] terminating execution
[5906] gw0-slave shutting down execution pool
[5906] gw0-slave [receiver-thread] closing read
[5906] gw0-slave [serve] joining receiver thread
[5906] gw0-slave waiting for receiver thread to finish
[5906] gw0-slave [receiver-thread] closing write
[5906] gw0-slave [receiver-thread] terminating our receive pseudo pool
[5903] gw0 [receiver-thread] EOF without prior gateway termination message
[5903] gw0 [receiver-thread] finishing receiving thread
[5903] gw0 [receiver-thread] terminating execution
[5903] gw0 [receiver-thread] closing read
[5903] gw0 [receiver-thread] closing write
[5903] gw0 [receiver-thread] terminating our receive pseudo pool
[5903] gw0 1 channel.__del__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment