Ask Solem 15 years ago
parent
commit
269feeb6c4
2 changed files with 27 additions and 25 deletions
  1. 4 3
      Changelog
  2. 23 22
      celery/managers.py

+ 4 - 3
Changelog

@@ -2,7 +2,7 @@
 Change history
 ==============
 
-0.6.0 [2009-07-29 01:59 P.M CET]
+0.6.0 [2009-08-07 06:54 A.M CET]
 --------------------------------
 
 **IMPORTANT CHANGES**
@@ -34,7 +34,7 @@ Change history
 	in the code for a long time)
 
 * New settings variable: ``CELERY_TASK_RESULT_EXPIRES``
-	Time (in seconds, or a :class:`datetime.timedelta` object) for when after
+	Time (in seconds, or a `datetime.timedelta` object) for when after
 	stored task results are deleted. For the moment this only works for the
 	database backend.
 
@@ -42,7 +42,8 @@ Change history
 	has been launched.
 
 * The periodic task table is now locked for reading while getting
-	periodic task status.
+	periodic task status. (MySQL only so far, seeking patches for other
+	engines)
 
 * A lot more debugging information is now available by turning on the
 	``DEBUG`` loglevel (``--loglevel=DEBUG``).

+ 23 - 22
celery/managers.py

@@ -13,34 +13,34 @@ SERVER_DRIFT = timedelta(seconds=random.vonmisesvariate(1, 4))
 
 
 class TableLock(object):
-   """Base class for database table locks. Also works as a NOOP lock."""
-  
-   def __init__(self, table, type="read"):
+    """Base class for database table locks. Also works as a NOOP lock."""
+
+    def __init__(self, table, type="read"):
         self.table = table
         self.type = type
         self.cursor = None
 
-   def lock_table(self):
-       """Lock the table."""
-       pass
+    def lock_table(self):
+        """Lock the table."""
+        pass
 
-   def unlock_table(self):
-       """Release previously locked tables."""
-       pass
+    def unlock_table(self):
+        """Release previously locked tables."""
+        pass
 
-   @classmethod
-   def acquire(cls, table, type=None):
-       """Acquire table lock."""
-       lock = cls(table, type)
-       lock.lock_table()
-       return lock
+    @classmethod
+    def acquire(cls, table, type=None):
+        """Acquire table lock."""
+        lock = cls(table, type)
+        lock.lock_table()
+        return lock
 
-   def release(self):
-       """Release the lock."""
-       self.unlock_table()
-       if self.cursor:
-           self.cursor.close()
-           self.cursor = None
+    def release(self):
+        """Release the lock."""
+        self.unlock_table()
+        if self.cursor:
+            self.cursor.close()
+            self.cursor = None
 
 
 class MySQLTableLock(TableLock):
@@ -49,7 +49,8 @@ class MySQLTableLock(TableLock):
     def lock_table(self):
         """Lock MySQL table."""
         self.cursor = connection.cursor()
-        self.cursor.execute("LOCK TABLES %s %s" % (self.table, self.type.upper()))
+        self.cursor.execute("LOCK TABLES %s %s" % (
+            self.table, self.type.upper()))
 
     def unlock_table(self):
         """Unlock MySQL table."""