calculator example issue

조회수 20회
읽지 않은 첫 메시지로 건너뛰기

Mike Arbelaez

읽지 않음,
2017. 5. 3. 오후 5:37:3217. 5. 3.
받는사람 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

읽지 않음,
2017. 5. 6. 오전 10:12:2317. 5. 6.
받는사람 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 :-(
 
전체답장
작성자에게 답글
전달
새 메시지 0개