gpt4 book ai didi

python - ZeroRPC 和 IronPython

转载 作者:太空宇宙 更新时间:2023-11-03 15:11:00 25 4
gpt4 key购买 nike

我真的很想使用优秀的 zerorpc对于我使用 IronPython 的项目,但它似乎不受支持。

我已经尝试下载 zerorpc 的源代码 zip 并运行

"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 .

我的问题:

  1. 是否可以让 zerorpc 与 IronPython 一起运行?如果可以,请告诉我如何操作?
  2. 如果没有,那么是否有任何其他等效包可以提供 IronPython 中的功能?这里有一个列表:What is the current choice for doing RPC in Python? ,但有人知道这些是否适用于 IronPython 吗?

更新 2按照@PawelJasinski 的建议和他对 pyzmq ironpython-backend 的更新,我尝试了以下操作:

  1. 已安装 IronPython 2.7.5b2 或更高版本
  2. http://zeromq.org/distro:microsoft-windows 安装了 32 位版本的 zeromq
  3. https://github.com/paweljasinski/pyzmq/tree/ironpython-backend 克隆 ironpython-backend 分支
  4. pyzmq 目录中,运行 ipy.exe setup.py install --user
  5. https://github.com/dotcloud/zerorpc-python 克隆 zerorpc
  6. zerorpc-python 中,运行 ipy.exe setup.py install --user
  7. 设置环境变量:set PYZMQ_BACKEND=zmq.backend.ctypes
  8. 尝试使用来自 https://github.com/dotcloud/zerorpc-python 的“Cooler”类示例, 运行 ipy.exe -X:Frames cooler.py

(冷却器.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

最佳答案

ZeroRPC 似乎是纯 python 并且基于 pyzmq。在这种情况下,您可以尝试 IronPython 的 pyzmq ctypes 后端。 https://github.com/paweljasinski/pyzmq/tree/ironpython-backend

  • 使用 IronPython 2.7.5b2 或更新版本
  • http://zeromq.org/distro:microsoft-windows 安装 32 位版本的 zmq
  • 安装 pyzmq 本身,克隆,而不是 ipy.exe setup.py install --user。安装应该检测到您的 zmq 并选择正确的 dll
  • 激活ctypes后端,设置环境变量PYZMQ_BACKEND=zmq.backend.ctypes

更新:ZeroRPC依赖于IronPython下不可用的gevent,因此以上说明仅对IronPython下的pyzmq有效

关于python - ZeroRPC 和 IronPython,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26719449/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com