From 7d7657f94af08e50a8b23b1c92e816c50e300cdc Mon Sep 17 00:00:00 2001 From: kindly Date: Fri, 12 Apr 2013 10:35:08 +0100 Subject: [PATCH] make gather phase as finished if there is an error --- ckanext/harvest/queue.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ckanext/harvest/queue.py b/ckanext/harvest/queue.py index 8fa1537..37e8c50 100644 --- a/ckanext/harvest/queue.py +++ b/ckanext/harvest/queue.py @@ -124,12 +124,15 @@ def gather_callback(channel, method, header, body): try: harvest_object_ids = harvester.gather_stage(job) - except Exception, e: + except (Exception, KeyboardInterrupt): channel.basic_ack(method.delivery_tag) + model.Session.query(HarvestObject).filter_by( + harvest_job_id=job.id + ).update(dict(state='ERROR', current=False)) raise - - job.gather_finished = datetime.datetime.now() - job.save() + finally: + job.gather_finished = datetime.datetime.now() + job.save() if not isinstance(harvest_object_ids, list): log.error('Gather stage failed')