Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8404365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:34:53+00:00 2026-06-09T22:34:53+00:00

I would like to set up an event-based system between my servers. For example,

  • 0

I would like to set up an event-based system between my servers. For example, when the server that wraps my database logic changes state, I would like for it to notify my other servers. A publish/subscribe design seems ideal for this, and I have heard good things about ZeroRPC.

Some people have mentioned using zerorpc streaming to accomplish pub/sub, however it’s not obvious to me how firing events would work using streaming.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:34:54+00:00Added an answer on June 9, 2026 at 10:34 pm

    At dotCloud we are using a lots of pub/sub trough zerorpc streaming. Let me describe our way to do it.

    In summary

    We expose a streaming method decorated with @zerorpc.stream. This method, when called, will add a gevent.queue to a set. Then the method will loop forever, yielding every messages arriving on the queue. When this method terminate (because the client disconnected), the queue is removed from the set.

    To publish, simply post the message to be published on every single queues registered in the set. At this time you have to decide what you want to do about slow consumers (disconnect them, queue for them up to a certain limit and/or discard new messages).

    Implementation example with zerorpc-python:

    The subscribing part

    class MyService(object):
        def __init__(self):
            self._subscribers = set()
    
        @zerorpc.stream
        def subscribe(self):
            try:
                queue = gevent.queue.Queue()
                self._subscribers.add(queue)
                for msg in queue:
                    yield msg
            finally:
                self._subscribers.remove(queue)
    

    The subscribe method simply add event queue to a set. Then consume the queue forever until either:
    – the queue is ended by a StopIteration message (see gevent.queue.Queue documentation)
    – the greenlet running the subscribe function is killed (usually because the client disconnected)

    In both cases, the finally statement is executed, and the queue is removed from the list of subscribers.

    Note that it is possible to limit the size of the queue at this point: ...Queue(maxsize=42).

    The publishing part

    class MyService(object):
        [...]
    
        def _publish(self, msg):
            for queue in self._subscribers:
                if queue.size < 42:
                    queue.put(msg)
    

    Call this method to publish a message. It will iterate over all the subscribers queues to put the message in it. In my example, if the queue reach reach a specific size, I discard the message. But there is no limit to what kind of pattern you want to apply there.

    You can store the greenlet instance of the subscriber in the set and then kill it when the queue is full, effectively disconnecting slow client (you can even try to send a message informing the client of being too slow). You could also wait for all your consumer to process the messages in parallel before returning from _publish, etc. The sky’s the limit my friend!

    Hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to set up a system that use both technologies at the
I would like to set up a very simple demo application that includes LINQ
I would like to set up an XSD such that it enforces something like
I used the same command syntax above as in Mysql and would like set
I would like to set some values in context.xml file and access the same
I would like to set the date in a Windows batch file to 7
I would like to set a variable in bash called test_var Basically, I want
I would like to set the css margin attribute of a standard tag (p
I would like to set a background image for the entire application for Windows
I would like to set some limits/boundaries on the amount of pixels we can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.