'Accepting New Events in PubNub While Others Are Still Processing

Newer beginner here!

I am attempting to automate the playing of a grindy game using multiple computers with Python.

This is how it works

  1. Computers 1, 2, ...., n stare at one area waiting for a specific colour to appear.
  2. When a colour appears on one of the computers, it sends a message "Computer n" to Computer 0 (The main computer) through PubNub.
  3. Computer 0 takes about 2 minutes to join the game of Computer n, perform an activity and leave.

The problem is that the colour can appear at any time - even simultaneously on multiple computers.

I only have one account on the main computer, so I'm fine with it taking 2 minutes each. Although it means that new events will be getting published while the previous is still processing. Once the backlog reaches more than 10 minutes I would like to ignore all new events as the main computer won't have time to reach them.

There is no way for me to currently tell how long the backlog is as I just process it in the Subscribe function. As soon as it finishes processing one event it immediately moves onto the next without being able to see how many more there are.

Is there a way I can add the events to a list while it's being processed at the same time? This would allow me to check how many events I have to do and ignore future ones if there are too many.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source