On 02/26/2013 12:10 AM, Adam Litke wrote:
On Thu, Feb 21, 2013 at 06:10:35PM +0800, ShaoHe Feng wrote:
Hi, Adam
An error arises, when I call json rpc server by AsyncoreReactor. And
I can call json rpc server successfully by a simple TCPReactor write
by myself.
how can I call json Rpc by AsyncoreReactor correctly?
address = ("127.0.0.1", 4044)
clientsReactor = asyncoreReactor.AsyncoreReactor()
reactor = TestClientWrapper(clientsReactor.createClient(address))
jsonAPI = JsonRpcClient(reactor)
jsonAPI.connect()
jsonAPI.callMethod("Host.ping", [], 1, 10)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/site-packages/yajsonrpc/client.py", line
39, in callMethod
resp = self._transport.recv(timeout=timeout)
File "/usr/share/vdsm/tests/jsonRpcUtils.py", line 100, in recv
return self._queue.get(timeout=timeout)[1]
File "/usr/lib64/python2.7/Queue.py", line 176, in get
raise Empty
Queue.Empty
Sheldon,
You and I resolved this problem but I will answer it here as well for the
benefit of everyone.
When using the Asyncore framework, there is a reactor on the server but also on
the client. Asyncore is multi-threaded and an event loop must be started for
the client reactor in order to process the server responses. See
tests/jsonRpcUtils.py:43 for the call to initialize the event loop thread in the
client reactor.
Yes. Thank you, Adam.
Now I can use the Asycore client reactor successfully.
But the jsonRpcUtils was in tests path. How about move it to yajson or
some other package.
Now, if I want to import TestClientWrapper from this module, I should
set the PYTHONPATH=/usr/share/vdsm/tests/
And without setting PYTHONPATH, I have added a __init__.py in my patch
to make the /usr/share/vdsm/tests/ as a python sitelib.
http://gerrit.ovirt.org/#/c/11283/
--
Sheldon Feng(冯少合)<shao...@linux.vnet.ibm.com>
IBM Linux Technology Center
_______________________________________________
vdsm-devel mailing list
vdsm-devel@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-devel