4

As you may know, ZeroRPC documentation is sparse. I can't get Streaming between a Python server and a Node client to work.

Here is the Python method:

@zerorpc.stream
def PublishWhaterver(self, some_args):
    yield "love"
    yield "stack"
    yield "overflow"

Here is the Node call:

export const tryStream = () => {
      connectedZerorpcClient.invoke('PublishWhatever', (error, res, more) => {
      console.log('STREAM', res, more);
  });
};

This code will log "STREAM love", and then do nothing.

So here are my questions:

  • In the Python server code, am I supposed to call PublishWhatever with relevant args so that it yield additionnal values ?
  • In the Node client, should I call some recursive function when there is more data ?

What I am trying to implement is a Pub/Sub system but right now implementation seems to only exists for a Python server and a Python client, there are no Node example.

The example on the main page and tests are not relevant either, it shows how to stream an array that already exists when the invoke method is called.Here the messages are generated during some heavy computations, I want the server to be able to tell the client "here, some data are ready" and never disconnect.

user3666197
  • 1
  • 6
  • 50
  • 92
Eric Burel
  • 3,790
  • 2
  • 35
  • 56

1 Answers1

3

Well, ZeroRPC actively promotes, that it is using its own python implementation code as a self-documentation how things work. In other words, no one has spent such additional efforts needed so as to publish a user-focused, the less a learning-process focused documentation.

Anyway, try to obey the few "visible" statements from the ZeroRPC description.

@zerorpc.stream
def PublishWhaterver(self, some_args):
    yield ( "love", "stack", "overflow", ) # one, tuple-wrapped result-container
user3666197
  • 1
  • 6
  • 50
  • 92
  • 1
    Hi, thanks for the answer. I eventually got it working. It works also with infinite generator, you can follow the Github link for more info. I still have issue with data processed by thread, I have hard time to yield value from an infinite queue, but that is a different question so I'll accept your answer. – Eric Burel Mar 13 '18 at 16:48