Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Reduce the possibility of deadlocks when incrementing media view counts

  • Loading branch information...
commit 9ef359607000380f082365aea00f7c59f3a1b5cc 1 parent 5eb9d49
@natedub natedub authored anthonyt committed
Showing with 6 additions and 2 deletions.
  1. +6 −2 mediacore/controllers/media.py
View
8 mediacore/controllers/media.py
@@ -27,6 +27,7 @@
from pylons import app_globals, config, request, response
from pylons.controllers.util import forward
from sqlalchemy import orm, sql
+from sqlalchemy.exc import OperationalError
from webob.exc import HTTPNotAcceptable, HTTPNotFound
from mediacore import USER_AGENT
@@ -161,7 +162,6 @@ def random(self, **kwargs):
redirect(action='view', slug=media.slug, podcast_slug=podcast_slug)
@expose('media/view.html')
- @autocommit
@observable(events.MediaController.view)
def view(self, slug, podcast_slug=None, **kwargs):
"""Display the media player, info and comments.
@@ -199,7 +199,11 @@ def view(self, slug, podcast_slug=None, **kwargs):
if url_for() != url_for(podcast_slug=media.podcast.slug):
redirect(podcast_slug=media.podcast.slug)
- media.increment_views()
+ try:
+ media.increment_views()
+ DBSession.commit()
+ except OperationalError:
+ DBSession.rollback()
# TODO: finish implementation of different 'likes' buttons
# e.g. the default one, plus a setting to use facebook.
Please sign in to comment.
Something went wrong with that request. Please try again.