0rpc / zerorpc-node

zerorpc for node.js
http://www.zerorpc.io
Other
704 stars 166 forks source link

Lost Remote Error #92

Closed chiaramdelucia closed 6 years ago

chiaramdelucia commented 6 years ago

Hello,

I am using zeropc-node on the client side and zerorpc-python on the server side.

The below code gives an error response 'Error: Lost remote after 10000ms'

Server Code

    @zerorpc.stream
    def stuff(self, num):
        for _ in xrange(73):
            time.sleep(0.2)
            yield num

Client Code

        client.invoke('stuff', 42, (error, res, more) => {
            if (error) {
                console.log(error);
            } else if (more) {
                console.log(res);
            }
        });

Any insight would be much appreciated.

Thank you.

chiaramdelucia commented 6 years ago

And, of course, I find this stackoverflow post AFTER I post my issue. gevent.sleep worked perfectly.

Thanks!

bigtreeIan commented 4 years ago

Hi, I also have the same problem, but I am quite confused about how to use gevent and where to add it. Any help would be appreciated! Thanks!

bombela commented 4 years ago

gevent gives you cooperative coroutine atop an IO loop. In other words, you have a single thread and many concurrent path of execution.

In order to make progress, you must always yield back the gevent loop, for it to poll IOs, and continue execution to the next pending coroutine.

Because of this you must never hold the CPU for too long (ideally, no more than few 100ms). time.sleep (blocking the current thread) becomes gevent.sleep (schedule current coroutine for later and yield to the gevent loop). subprocess.Popen would block the thread, but gevent.Popen will not, etc.

ludakis commented 4 years ago

And, of course, I find this stackoverflow post AFTER I post my issue. gevent.sleep worked perfectly.

Thanks!

Please where did you add gevent.sleep ?