Skip to content Skip to sidebar Skip to footer

How To Run Zerorpc As A Greenlet?

I want to run a zeroRPC server as a greenlet with other gevent greenlets in the same loop. The documentation of ZeroRPC is a little light. This is the suggested way to start a zero

Solution 1:

This is the best way to do it.

The .run() method will take care of setting up the (zerorpc) server, spawning and managing any sub-greenlets as needed. This effectively creates a tree of greenlet, bubbling up any fatal errors back to the .run() method. The zerorpc server will run any incoming request in a new greenlet, spawned from the tree of greenlet owned by the .run() method.

Having a blocking .run() method let you handle errors raised by .run() with a simple try/catch. Additionally, when .run() returns, it means the zerorpc server is fully stopped. For example, when you call .stop() from another greenlet, the zerorpc server will stop accepting new requests and finish processing active requests before returning from .run()

Post a Comment for "How To Run Zerorpc As A Greenlet?"