Pārlūkot izejas kodu

PEP8ify, catch Exception instead of naked except in jkozeras patch

Ask Solem 15 gadi atpakaļ
vecāks
revīzija
ac2a4a6d20
2 mainītis faili ar 5 papildinājumiem un 6 dzēšanām
  1. 5 5
      celery/managers.py
  2. 0 1
      celery/worker/job.py

+ 5 - 5
celery/managers.py

@@ -80,7 +80,8 @@ class TaskManager(models.Manager):
         """Delete all expired task results."""
         """Delete all expired task results."""
         self.get_all_expired().delete()
         self.get_all_expired().delete()
 
 
-    def store_result(self, task_id, result, status, traceback=None, exception_retry=True):
+    def store_result(self, task_id, result, status, traceback=None,
+            exception_retry=True):
         """Store the result and status of a task.
         """Store the result and status of a task.
 
 
         :param task_id: task id
         :param task_id: task id
@@ -95,8 +96,8 @@ class TaskManager(models.Manager):
         :keyword traceback: The traceback at the point of exception (if the
         :keyword traceback: The traceback at the point of exception (if the
             task failed).
             task failed).
 
 
-        :keyword exception_retry: If we should retry storing by rollbacking 
-            transaction on exception
+        :keyword exception_retry: If True, we try a single retry with
+            transaction rollback on exception
         """
         """
         try:
         try:
             task, created = self.get_or_create(task_id=task_id, defaults={
             task, created = self.get_or_create(task_id=task_id, defaults={
@@ -108,7 +109,7 @@ class TaskManager(models.Manager):
                 task.result = result
                 task.result = result
                 task.traceback = traceback
                 task.traceback = traceback
                 task.save()
                 task.save()
-        except:
+        except Exceptions, exc:
             # depending on the database backend we can get various exceptions.
             # depending on the database backend we can get various exceptions.
             # for excample, psycopg2 raises an exception if some operation
             # for excample, psycopg2 raises an exception if some operation
             # breaks transaction, and saving task result won't be possible
             # breaks transaction, and saving task result won't be possible
@@ -120,7 +121,6 @@ class TaskManager(models.Manager):
                 raise
                 raise
 
 
 
 
-
 class PeriodicTaskManager(models.Manager):
 class PeriodicTaskManager(models.Manager):
     """Manager for :class:`celery.models.PeriodicTask` models."""
     """Manager for :class:`celery.models.PeriodicTask` models."""
 
 

+ 0 - 1
celery/worker/job.py

@@ -11,7 +11,6 @@ from celery.log import get_default_logger
 from django.core.mail import mail_admins
 from django.core.mail import mail_admins
 import socket
 import socket
 
 
-
 # pep8.py borks on a inline signature separator and
 # pep8.py borks on a inline signature separator and
 # says "trailing whitespace" ;)
 # says "trailing whitespace" ;)
 EMAIL_SIGNATURE_SEP = "-- "
 EMAIL_SIGNATURE_SEP = "-- "