Using IPython with RubyPython leads to problems with IPython.parallel.client.client.Client.__init() #488

Closed
kaazoo opened this Issue May 31, 2011 · 5 comments

Comments

Projects
None yet
3 participants

kaazoo commented May 31, 2011

I would like to use IPython also from Ruby with the help of RubyPython, a Ruby library which includes a Python interpreter into Ruby. The cause for that is reusing an existing web application based on RubyOnRails.

To find out, if this is a problem of IPython or RubyPython, I've also created a ticket at https://bitbucket.org/raineszm/rubypython/issue/5/rubypython-seems-to-call-wrong-new-method . The developer of RubyPython says that "something is going wrong in the Client class's init method within the IPython code".

If I create an object of the IPython class IPython.parallel.client.client.Client it works at the first time. If I do the same thing again, I get "TypeError: an integer is required". The developer tracked it down to

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/DrQueue/client.py", line 23, in __init__
    self.ip_client = IPClient()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/parallel/client/client.py", line 244, in __init__
    context = zmq.Context.instance()
  File "context.pyx", line 72, in zmq.core.context.Context.instance (zmq/core/context.c:957)

Do you have an idea?

Owner

takluyver commented May 31, 2011

Looking at the ZMQ code (https://github.com/zeromq/pyzmq/blob/master/zmq/core/context.pyx), line 72 is the definition of the Context.instance() classmethod, which has a default integer argument. Could RubyPython somehow be mishandling this, perhaps by filling in None as the argument, overriding the default? As far as I can see, the Client.__init__() code is all correct.

Owner

minrk commented May 31, 2011

Can you test a simple case by doing:

require "rubygems"
require "rubypython"
RubyPython.start
zmq = RubyPython.import("zmq")
ctx = zmq.Context.instance()

What versions of pyzmq and rubypython are you using?

That code works for me, as does creating an IPython client from RubyPython.

Owner

minrk commented May 31, 2011

Sorry, I re-read the other issue, and I can reproduce the issue with:

require "rubygems"
require "rubypython"

RubyPython.start
zmq = RubyPython.import("zmq")
ctx = zmq.Context.instance(2)
RubyPython.stop
RubyPython.start
zmq = RubyPython.import("zmq")
puts zmq.Context.instance(2)
RubyPython.stop

Which produces the error: TypeError: instance() takes at most 1 positional argument (2 given). This reveals that the second time the interpreter is started, the classmethod is not properly a classmethod, and the class itself is being passed as the argument, instead of iothreads.

I don't know if this is the fault of RubyPython or Cython, but one of the two is definitely doing something wrong, because the Context class is certainly not being constructed correctly at the second invocation of the interpreter.

In the meantime, you can get prevent this call to Context.instance() if you create a Context yourself, and pass it to the Client constructor.

kaazoo commented May 31, 2011

Thank you very much. I will point RubyPython's developer to this ticket, so he might see where the problem could be.

Owner

takluyver commented May 31, 2011

Glad progress is being made. It's clear now that this isn't an IPython issue, so I'll close it.

takluyver closed this May 31, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment