calculator example issue

20 views
Skip to first unread message

Mike Arbelaez

unread,
May 3, 2017, 5:37:32 PM5/3/17
to python-pulsar
Hello,

I'm excited to try out pulsar and was running through the first example which is the calculator. When i follow the instructions i'm not seeing the return pong but rather the coroutine object.

I have the server running in one terminal and I'm using the REPL in another terminal to do the commands below.

>>> from pulsar.apps import rpc
>>> p = rpc.JsonProxy('http://127.0.0.1:8060')
>>> p.ping()
<coroutine object _call at 0x108057678>
>>> p.calc.add(3,4)
<coroutine object _call at 0x10809e258>

Is there something I'm doing wrong?

lsbardel

unread,
May 6, 2017, 10:12:23 AM5/6/17
to python-pulsar

>>> from pulsar.apps import rpc
>>> p = rpc.JsonProxy('http://127.0.0.1:8060')
>>> p.ping()
<coroutine object _call at 0x108057678>
>>> p.calc.add(3,4)
<coroutine object _call at 0x10809e258>

Is there something I'm doing wrong?
 
The rpc client is asynchronous and it returns a coroutine.
To use it in the python shell you need to explicitly call the event loop "run_until_complete" method

p._loop.run_until_complete(p.calc.add(3,4))

I need to update the documentation :-(
 
Reply all
Reply to author
Forward
0 new messages