aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/submit/lib.py
diff options
context:
space:
mode:
authorElrond <elrond+mediagoblin.org@samba-tng.org>2012-12-17 19:54:26 +0100
committerElrond <elrond+mediagoblin.org@samba-tng.org>2012-12-26 23:42:26 +0100
commit86bb44ef121e64e2a2c7ad175af444000a7ca0c9 (patch)
tree594c719ca85b7a8263b28bf6f949a07e9f9b86fb /mediagoblin/submit/lib.py
parentbe1f0f7d33440d96c2bcc1c7f3dfd5cbb356e54f (diff)
downloadmediagoblin-86bb44ef121e64e2a2c7ad175af444000a7ca0c9.tar.lz
mediagoblin-86bb44ef121e64e2a2c7ad175af444000a7ca0c9.tar.xz
mediagoblin-86bb44ef121e64e2a2c7ad175af444000a7ca0c9.zip
Factor out the actual calling of the processing.
Calling the processing task and handling the exceptions is easy, but has a bunch of caveats, so factor it out into an easy callable function.
Diffstat (limited to 'mediagoblin/submit/lib.py')
-rw-r--r--mediagoblin/submit/lib.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/mediagoblin/submit/lib.py b/mediagoblin/submit/lib.py
index 57069e84..f174d4ea 100644
--- a/mediagoblin/submit/lib.py
+++ b/mediagoblin/submit/lib.py
@@ -17,12 +17,36 @@
import urllib
import urllib2
import logging
+from celery import registry
from mediagoblin import mg_globals
+from mediagoblin.processing import mark_entry_failed
+from mediagoblin.processing.task import ProcessMedia
+
_log = logging.getLogger(__name__)
+def run_process_media(entry):
+ process_media = registry.tasks[ProcessMedia.name]
+ try:
+ process_media.apply_async(
+ [unicode(entry.id)], {},
+ task_id=entry.queued_task_id)
+ except BaseException as exc:
+ # The purpose of this section is because when running in "lazy"
+ # or always-eager-with-exceptions-propagated celery mode that
+ # the failure handling won't happen on Celery end. Since we
+ # expect a lot of users to run things in this way we have to
+ # capture stuff here.
+ #
+ # ... not completely the diaper pattern because the
+ # exception is re-raised :)
+ mark_entry_failed(entry.id, exc)
+ # re-raise the exception
+ raise
+
+
def handle_push_urls(request):
if mg_globals.app_config["push_urls"]:
feed_url = request.urlgen(