aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoar Wandborg <git@wandborg.com>2012-09-25 01:06:25 +0200
committerJoar Wandborg <git@wandborg.com>2012-09-26 23:53:51 +0200
commit939d57a022daa8f1f08dcfd111385225ca6030f6 (patch)
tree9e2f1c2359431a42e4a445f8ef34a35d0c0c7e63
parent5354f954dc94aafd35bc037faad2412f73320d8c (diff)
downloadmediagoblin-939d57a022daa8f1f08dcfd111385225ca6030f6.tar.lz
mediagoblin-939d57a022daa8f1f08dcfd111385225ca6030f6.tar.xz
mediagoblin-939d57a022daa8f1f08dcfd111385225ca6030f6.zip
HTTP callback fixes
- Added HTTPError catching around the callback request, to not mark the entry as failed, just log the exception. - Fixed bug where I forgot to actually fetch the entry before passing it to json_processing_callback. - Changed __main__ migration #6 to create the ProcessingMetaData table as it is currently, to prevent possible breakage if a siteadmin is lagging behind with his db migrations and more than one migration wants to fix stuff with the ProcessingMetaData table.
-rw-r--r--mediagoblin/db/sql/migrations.py10
-rw-r--r--mediagoblin/processing/task.py2
-rw-r--r--mediagoblin/tools/processing.py15
3 files changed, 21 insertions, 6 deletions
diff --git a/mediagoblin/db/sql/migrations.py b/mediagoblin/db/sql/migrations.py
index 416c076b..1d822cd9 100644
--- a/mediagoblin/db/sql/migrations.py
+++ b/mediagoblin/db/sql/migrations.py
@@ -106,5 +106,13 @@ def add_mediaentry_collected(db_conn):
@RegisterMigration(6, MIGRATIONS)
def create_processing_metadata_table(db):
- ProcessingMetaData.__table__.create(db.bind)
+ metadata = MetaData(bind=db.bind)
+
+ metadata_table = Table('core__processing_metadata', metadata,
+ Column('id', Integer, primary_key=True),
+ Column('media_entry_id', Integer, ForeignKey(MediaEntry.id),
+ nullable=False, index=True),
+ Column('callback_url', Unicode))
+
+ metadata_table.create()
db.commit()
diff --git a/mediagoblin/processing/task.py b/mediagoblin/processing/task.py
index 7f4b8429..187b893d 100644
--- a/mediagoblin/processing/task.py
+++ b/mediagoblin/processing/task.py
@@ -96,5 +96,5 @@ class ProcessMedia(Task):
entry_id = args[0]
mark_entry_failed(entry_id, exc)
- entry = mgg.database.MediaEntry.query.filter_by(id=entry_id)
+ entry = mgg.database.MediaEntry.query.filter_by(id=entry_id).first()
json_processing_callback(entry)
diff --git a/mediagoblin/tools/processing.py b/mediagoblin/tools/processing.py
index 41a0a5fa..5840c7e0 100644
--- a/mediagoblin/tools/processing.py
+++ b/mediagoblin/tools/processing.py
@@ -16,8 +16,9 @@
import logging
import json
+import traceback
-from urllib2 import urlopen, Request
+from urllib2 import urlopen, Request, HTTPError
from urllib import urlencode
_log = logging.getLogger(__name__)
@@ -67,7 +68,13 @@ def json_processing_callback(entry):
headers=headers,
data_parser=json.dumps)
- urlopen(request)
- _log.debug('Processing callback for {0} sent'.format(entry))
+ try:
+ urlopen(request)
+ _log.debug('Processing callback for {0} sent'.format(entry))
- return True
+ return True
+ except HTTPError:
+ _log.error('Failed to send callback: {0}'.format(
+ traceback.format_exc()))
+
+ return False