Commits

Jason R. Coombs committed f99132d

Fix error where lock and unlock do not take a parameter.

Comments (0)

Files changed (1)

cherrypy/lib/lockfile.py

 
         try:
             # Open lockfile for writing without truncation:
-            fp = open(path, 'r+')
+            self.fp = open(path, 'r+')
         except IOError:
             # If the file doesn't exist, IOError is raised; Use a+ instead.
             # Note that there may be a race here. Multiple processes
             # could fail on the r+ open and open the file a+, but only
             # one will get the the lock and write a pid.
-            fp = open(path, 'a+')
+            self.fp = open(path, 'a+')
 
         try:
-            self._lock_file(fp)
+            self._lock_file()
         except:
-            fp.seek(1)
-            fp.close()
+            self.fp.seek(1)
+            self.fp.close()
+            del self.fp
             raise
 
-        self.fp = fp
-        fp.write(" %s\n" % os.getpid())
-        fp.truncate()
-        fp.flush()
+        self.fp.write(" %s\n" % os.getpid())
+        self.fp.truncate()
+        self.fp.flush()
 
     def release(self):
         if not hasattr(self, 'fp'):