Created
February 14, 2012 07:19
-
-
Save autre/1824467 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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