我真的想在我使用IronPython的项目中使用优秀的zerorpc,但它似乎不受支持。
我尝试下载zerorpc
的源代码拉链并运行
"C:\Program Files (x86)\IronPython 2.7\ipy.exe" setup.py install
但我在此过程中看到了这一点:
warning: build_py: byte-compiling is disabled, skipping.
这与答案不一致:Fast and scalable RPC between C# and CPython。
我的问题:
更新2 根据@PawelJasinski的建议以及他对pyzmq ironpython-backend的更新,我尝试了以下内容:
ironpython-backend
分支
pyzmq
目录中,运行ipy.exe setup.py install --user
zerorpc-python
中,运行ipy.exe setup.py install --user
set PYZMQ_BACKEND=zmq.backend.ctypes
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()
现在我看到了这个错误:
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
答案 0 :(得分:2)
ZeroRPC似乎是纯Python,基于pyzmq。在这种情况下,您可以为IronPython尝试pyzmq ctypes
后端。 https://github.com/paweljasinski/pyzmq/tree/ironpython-backend
ipy.exe setup.py install --user
。安装应检测您的zmq并选择正确的dll PYZMQ_BACKEND=zmq.backend.ctypes
更新:ZeroRPC依赖于gevent
,这在IronPython下是不可用的,因此上述说明仅适用于IronPython下的pyzmq
答案 1 :(得分:2)