- #__import__(entry.media_type)
- manager = get_media_manager(entry.media_type)
- _log.debug('Processing {0}'.format(entry))
- manager['processor'](entry)
- except BaseProcessingFail, exc:
- mark_entry_failed(entry._id, exc)
+ processor_class = manager.get_processor(reprocess_action, entry)
+
+ with processor_class(manager, entry) as processor:
+ # Initial state change has to be here because
+ # the entry.state gets recorded on processor_class init
+ entry.state = u'processing'
+ entry.save()
+
+ _log.debug('Processing {0}'.format(entry))
+
+ try:
+ processor.process(**reprocess_info)
+ except Exception as exc:
+ if processor.entry_orig_state == 'processed':
+ _log.error(
+ 'Entry {0} failed to process due to the following'
+ ' error: {1}'.format(entry.id, exc))
+ _log.info(
+ 'Setting entry.state back to "processed"')
+ pass
+ else:
+ raise
+
+ # We set the state to processed and save the entry here so there's
+ # no need to save at the end of the processing stage, probably ;)
+ entry.state = u'processed'
+ entry.save()
+
+ # Notify the PuSH servers as async task
+ if mgg.app_config["push_urls"] and feed_url:
+ handle_push_urls.subtask().delay(feed_url)
+
+ json_processing_callback(entry)
+ except BaseProcessingFail as exc:
+ mark_entry_failed(entry.id, exc)
+ json_processing_callback(entry)