From b4de2ee0f9c68be3549adba0b7f651c6e9a8465a Mon Sep 17 00:00:00 2001 From: James Turk Date: Tue, 15 May 2012 17:05:19 -0400 Subject: [PATCH] print summary --- oyster/scripts/signal.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/oyster/scripts/signal.py b/oyster/scripts/signal.py index e6e6faf..3106ee2 100644 --- a/oyster/scripts/signal.py +++ b/oyster/scripts/signal.py @@ -1,5 +1,6 @@ #!/usr/bin/env python import argparse +import traceback from celery.execute import send_task from celery import current_app @@ -28,11 +29,20 @@ def main(): docs = docs.limit(100) args.immediate = True + total = docs.count() + errors = 0 + if args.immediate: module, name = args.task.rsplit('.', 1) task = getattr(__import__(module, fromlist=[name]), name) for doc in docs: - task.apply((doc['_id'],), throw=True) + try: + task.apply((doc['_id'],), throw=True) + except Exception: + errors += 1 + traceback.print_exc() + print '{0} errors in {1} documents'.format(errors, total) + else: for doc in docs: send_task(args.task, (doc['_id'], ))