pulsards client can not running?

18 views
Skip to first unread message

Bright Pan

unread,
Mar 16, 2016, 8:08:37 AM3/16/16
to python-pulsar
i use pulsards example for python3.5,

 for server:
from pulsar.apps.data import PulsarDS
if __name__ == '__main__':
   
PulsarDS().start()

for client
>>> from pulsar.apps.data import create_store
>>> store = create_store('pulsar://localhost:6410')
>>> client = store.client()
>>> client.ping()
<generator object execute at 0x1114fd6d0>
>>> client.echo('Hello!')
<generator object execute at 0x1114fd645>
 the result for client.ping() is not True, Why?

lsbardel

unread,
Mar 16, 2016, 6:47:37 PM3/16/16
to python-pulsar


Hi,

On Wednesday, March 16, 2016 at 12:08:37 PM UTC, Bright Pan wrote:
i use pulsards example for python3.5,
 
for client
>>> from pulsar.apps.data import create_store
>>> store = create_store('pulsar://localhost:6410')
>>> client = store.client()
>>> client.ping()
<generator object execute at 0x1114fd6d0>
>>> client.echo('Hello!')
<generator object execute at 0x1114fd645>
 the result for client.ping() is not True, Why?
 
Because the response is asynchronous.
You need to use these methods in a coroutine, alternatively in the shell you need to run the loop until the coroutine has finished:

>>> client._loop.run_until_complete(client.ping())
True

>>> client._loop.run_until_complete(client.echo('Hello!'))

b'Hello!'



Reply all
Reply to author
Forward
0 new messages