1
我的安裝程序有一個生成的Node.js子代,它創建了一個Python對象的2路ZeroRPC會話對。Python客戶端調用中的雙向ZeroRPC導致AssertionError
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
方法調用?還是有一些我可以忽略的其他技巧?