Skip to content

Commit

Permalink
Rename _pidfile_wrote to unlink_pidfile for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
mnaberez committed Apr 25, 2017
1 parent d24fca4 commit ff46250
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
7 changes: 3 additions & 4 deletions supervisor/options.py
Expand Up @@ -416,6 +416,7 @@ class ServerOptions(Options):
nodaemon = None
environment = None
httpservers = ()
unlink_pidfile = False
unlink_socketfiles = True
mood = states.SupervisorStates.RUNNING

Expand Down Expand Up @@ -464,8 +465,6 @@ def __init__(self):
self.signal_receiver = SignalReceiver()
self.poller = poller.Poller(self)

self._pidfile_wrote = False

def version(self, dummy):
"""Print version to stdout and exit(0).
"""
Expand Down Expand Up @@ -1153,7 +1152,7 @@ def write_pidfile(self):
except (IOError, OSError):
self.logger.critical('could not write pidfile %s' % self.pidfile)
else:
self._pidfile_wrote = True
self.unlink_pidfile = True
self.logger.info('supervisord started with pid %s' % pid)

def cleanup(self):
Expand All @@ -1162,7 +1161,7 @@ def cleanup(self):
if self.unlink_socketfiles:
socketname = config['file']
self._try_unlink(socketname)
if self._pidfile_wrote:
if self.unlink_pidfile:
self._try_unlink(self.pidfile)
self.poller.close()

Expand Down
10 changes: 5 additions & 5 deletions supervisor/tests/test_options.py
Expand Up @@ -1360,7 +1360,7 @@ def test_cleanup_removes_pidfile(self):
instance.pidfile = pidfile
instance.logger = DummyLogger()
instance.write_pidfile()
self.assertTrue(instance._pidfile_wrote)
self.assertTrue(instance.unlink_pidfile)
instance.cleanup()
self.assertFalse(os.path.exists(pidfile))
finally:
Expand All @@ -1383,11 +1383,11 @@ def test_cleanup_does_not_remove_pidfile_from_another_supervisord(self):

try:
instance = self._makeOne()
# pidfile exists but _pidfile_wrote indicates we did not write it.
# pidfile exists but unlink_pidfile indicates we did not write it.
# pidfile must be from another instance of supervisord and
# shouldn't be removed.
instance.pidfile = pidfile
self.assertFalse(instance._pidfile_wrote)
self.assertFalse(instance.unlink_pidfile)
instance.cleanup()
self.assertTrue(os.path.exists(pidfile))
finally:
Expand Down Expand Up @@ -1513,7 +1513,7 @@ def test_write_pidfile_ok(self):
self.assertEqual(pid, os.getpid())
msg = instance.logger.data[0]
self.assertTrue(msg.startswith('supervisord started with pid'))
self.assertTrue(instance._pidfile_wrote)
self.assertTrue(instance.unlink_pidfile)
finally:
try:
os.unlink(fn)
Expand All @@ -1528,7 +1528,7 @@ def test_write_pidfile_fail(self):
instance.write_pidfile()
msg = instance.logger.data[0]
self.assertTrue(msg.startswith('could not write pidfile'))
self.assertFalse(instance._pidfile_wrote)
self.assertFalse(instance.unlink_pidfile)

def test_close_fd(self):
instance = self._makeOne()
Expand Down

0 comments on commit ff46250

Please sign in to comment.