def test_pidfile(self): proc = subprocess.Popen('sleep 120', shell=True) fd, path = tempfile.mkstemp() os.close(fd) try: pidfile = Pidfile(path) pidfile.create(proc.pid) self.assertRaises(RuntimeError, pidfile.create, proc.pid) pidfile.unlink() pidfile.create(proc.pid) pidfile.rename(path + '.2') self.assertTrue(os.path.exists(path + '.2')) self.assertFalse(os.path.exists(path)) finally: os.remove(path + '.2')
def test_pidfile(self): cmd = shlex.split(SLEEP % 120, posix=not IS_WINDOWS) proc = subprocess.Popen(cmd, shell=True) fd, path = tempfile.mkstemp() os.close(fd) try: pidfile = Pidfile(path) pidfile.create(proc.pid) self.assertRaises(RuntimeError, pidfile.create, proc.pid) pidfile.unlink() pidfile.create(proc.pid) pidfile.rename(path + '.2') self.assertTrue(os.path.exists(path + '.2')) self.assertFalse(os.path.exists(path)) finally: os.remove(path + '.2')
def test_pidfile(self): cmd = shlex.split(SLEEP % 120, posix=not IS_WINDOWS) proc = subprocess.Popen(cmd, shell=True) fd, path = tempfile.mkstemp() os.close(fd) try: pidfile = Pidfile(path) pidfile.create(proc.pid) self.assertRaises(RuntimeError, pidfile.create, proc.pid) pidfile.unlink() pidfile.create(proc.pid) pidfile.rename(path + ".2") self.assertTrue(os.path.exists(path + ".2")) self.assertFalse(os.path.exists(path)) finally: os.remove(path + ".2")
def test_pidfile(self): proc = subprocess.Popen(SLEEP % 120, shell=True) fd, path = tempfile.mkstemp() os.close(fd) rf = path + '.2' try: pidfile = Pidfile(path) pidfile.create(proc.pid) mode = os.stat(path).st_mode self.assertEqual(stat.S_IMODE(mode), pidfile.perm_mode, path) pidfile.unlink() self.assertFalse(os.path.exists(path)) pidfile.create(proc.pid) pidfile.rename(rf) self.assertTrue(os.path.exists(rf)) self.assertFalse(os.path.exists(path)) mode = os.stat(rf).st_mode self.assertEqual(stat.S_IMODE(mode), pidfile.perm_mode, rf) finally: os.remove(rf)