Skip to content

Instantly share code, notes, and snippets.

@autre
Created February 14, 2012 07:19
Show Gist options
  • Save autre/1824467 to your computer and use it in GitHub Desktop.
Save autre/1824467 to your computer and use it in GitHub Desktop.
from monitoring import notification
# a callback to print each notification to stderr
def print_notification(event_list):
for e in event_list:
print >> sys.stderr, e
# a callback to write each event to the db
def write_to_db(event_list):
for e in event_list:
db.insert(e)
# main:
# the following callbacks will be called
# asynchronously to the program loop below
notification.register('foo-topic', print_notification)
notification.register('bar-topic', write_to_db)
while true:
compute_some_value()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment