Event handling from within RPC?


Is there a way to have an RPC listen for an event inline?

I have an RPC that triggers an external action, and then it needs to wait until that action is complete before it can return. I can poll for the status of the external action, but the result of the external action also triggers an event in Nameko that I would like the RPC to be able to receive so it doesn’t have to poll.

I could have the RPC method block on a Redis key, and an event handler listen for the event and then set the key, but it adds complexity that seems unnecessary.

Is there an easier way?




Hi Bob,

I’d do exactly as you’ve described and use a redis lock.

There’s no out of the box way to do “inline” listening for events like this. You could write a DependencyProvider that spawned a thread with an AMQP consumer which would block until the event arrived. It wouldn’t be a lot of code. But an event handler that just set the redis key would be even less.