Captain Whippet
Captain Whippet

Reputation: 2223

ZeroRPC and IronPython

I would really like to use the excellent zerorpc for my project that uses IronPython, but it doesn't seem to be supported.

I have tried downloading the zip of the source for zerorpc and running

"C:\Program Files (x86)\IronPython 2.7\ipy.exe" setup.py install

but I see this along the way:

warning: build_py: byte-compiling is disabled, skipping.

This does not contradict the answer: Fast and scalable RPC between C# and CPython.

My question(s):

  1. Is it possible to get zerorpc running with IronPython and if so, please could you give me a hint of how to do it?
  2. If not, then are there any other equivalent packages that would provide the functionality in IronPython? There's a list here: What is the current choice for doing RPC in Python?, but does anyone know if any of these work with IronPython?

Update 2 Following @PawelJasinski suggestion and his updates to pyzmq ironpython-backend, I have tried the following:

  1. Installed IronPython 2.7.5b2 or later
  2. Installed 32 bit version of zeromq from http://zeromq.org/distro:microsoft-windows
  3. Clone ironpython-backend branch from https://github.com/paweljasinski/pyzmq/tree/ironpython-backend
  4. In pyzmq dir, run ipy.exe setup.py install --user
  5. Clone zerorpc from https://github.com/dotcloud/zerorpc-python
  6. In zerorpc-python, run ipy.exe setup.py install --user
  7. Set the environment variable: set PYZMQ_BACKEND=zmq.backend.ctypes
  8. Attempted to use the 'Cooler' class example from https://github.com/dotcloud/zerorpc-python, running with ipy.exe -X:Frames cooler.py

(cooler.py):

class Cooler(object):
    """ Various convenience methods to make things cooler. """

    def add_man(self, sentence):
        """ End a sentence with ", man!" to make it sound cooler, and
        return the result. """
        return sentence + ", man!"

    def add_42(self, n):
        """ Add 42 to an integer argument to make it cooler, and return the
        result. """
        return n + 42

    def boat(self, sentence):
        """ Replace a sentence with "I'm on a boat!", and return that,
        because it's cooler. """
        return "I'm on a boat!"

import zerorpc

s = zerorpc.Server(Cooler())
s.bind("tcp://0.0.0.0:4242")
s.run()

Now I see this error:

Traceback (most recent call last):
  File "C:\Users\nlindop\AppData\Roaming\Python\IronPython27\site-packages\zmq\backend\select.py", line 26, in select_backend
  File "C:\Users\nlindop\AppData\Roaming\Python\IronPython27\site-packages\zmq\backend\ctypes\__init__.py", line 26, in <module>
  File "C:\Users\nlindop\AppData\Roaming\Python\IronPython27\site-packages\zmq\backend\ctypes\constants.py", line 16, in <module>
ImportError: No module named ZMQ

Upvotes: 3

Views: 777

Answers (2)

Pawel Jasinski
Pawel Jasinski

Reputation: 796

For the second part of the question. pyro (and its dependency serpent) support IronPython and Jython.

Warning: stay away from IronPython 2.7.5b3 - it has a bug which breaks serpent. 2.7.4 and 2.7.5b2 are ok. Next 2.7.5 has a fix.

Upvotes: 2

Pawel Jasinski
Pawel Jasinski

Reputation: 796

ZeroRPC appears to be pure python and is based on pyzmq. In this case you can try pyzmq ctypes backend for IronPython. https://github.com/paweljasinski/pyzmq/tree/ironpython-backend

  • use IronPython 2.7.5b2 or newer
  • install 32-bit version of zmq from http://zeromq.org/distro:microsoft-windows
  • install pyzmq itself, clone, than ipy.exe setup.py install --user. Install should detect your zmq and pick the right dll
  • activate the ctypes backend, set the environment variable PYZMQ_BACKEND=zmq.backend.ctypes

UPDATE: ZeroRPC has dependency on gevent which is not available under IronPython, so the above instructions are valid only for pyzmq under IronPython

Upvotes: 2

Related Questions