私のセットアップでは、Python オブジェクトを使用してセッションの双方向 ZeroRPC ペアを作成する Node.js 子が生成されています。
Python 側は次のようになります。
class MyClass:
def __init__(self, socketpath):
self.client = zerorpc.Client()
self.client.connect(socketpath)
def sendtoclient(self, msg):
self.client.receiveMessage(msg)
if __name__ == '__main__':
zpc = zerorpc.Server(MyClass(sys.argv[1]))
zpc.bind(sys.argv[1] + "_python")
zpc.run()
Node.js 子クライアントは Python サーバーでメソッドを呼び出すことができますが、そのサーバー内のクライアントは、例外を取得せずに Node.js 子サーバーで呼び出すことはできません。
Traceback (most recent call last):
File "/usr/lib64/python2.6/site-packages/gevent/queue.py", line 271, in _unlock getter.switch(getter)
File "/usr/lib64/python2.6/site-packages/gevent/hub.py", line 534, in switch assert getcurrent() is self.hub, "Can only use Waiter.switch method from the Hub greenlet"
AssertionError: Can only use Waiter.switch method from the Hub greenlet
<callback at 0x3055e90 args=()> failed with AssertionError
Python クラスのクライアントを gevent として生成し、必要に応じてそのreceiveMessage
メソッドを呼び出す必要がありますか? または、私が見落としている他のトリックはありますか?