Commits

Horst Gutmann  committed 3c2c9ea

Fixed a small problem where the PID was actually not in the lockfile

  • Participants
  • Parent commits d3635bb

Comments (0)

Files changed (2)

File tests/contexts/file_singleton_test.py

             with open(self.lockfile, 'r') as fp:
                 fp.read()
 
+    def testPidInLock(self):
+        """Make sure that the current pid is in the lockfile"""
+        with FileSingletonContext(self.lockfile):
+            with open(self.lockfile, 'r') as fp:
+                self.assertEqual(int(fp.read()), os.getpid())

File zs/utils/contexts/file_singleton.py

         
     def __enter__(self):
         try:
-            fd = os.open(self.pid_file, os.O_CREAT|os.O_EXCL)
+            fd = os.open(self.pid_file, os.O_CREAT|os.O_EXCL|os.O_RDWR)
             try:
                 os.write(fd, str(os.getpid()))
             finally: