Skip to content

Commit

Permalink
Clarify what the lock is for
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvipanda committed Dec 26, 2018
1 parent 892411d commit 0666875
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions simpervisor/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def __init__(self, name, *args, always_restart=False, **kwargs):
# Don't restart process if we explicitly kill it
self._killed = False

# Only one coroutine should be starting or killing a process at a time
self._start_stop_lock = asyncio.Lock()
# The 'process' is a shared resource, and protected by this lock
self._proc_lock = asyncio.Lock()

self.log = logging.getLogger('simpervisor')

Expand Down Expand Up @@ -50,7 +50,7 @@ async def start(self):
"""
Start the process
"""
with (await self._start_stop_lock):
with (await self._proc_lock):
if self.running:
# Don't wanna start it again, if we're already running
return
Expand Down Expand Up @@ -81,7 +81,7 @@ async def _restart_process_if_needed(self):

async def _signal_and_wait(self, signum):
# We don't want this to race with start
with (await self._start_stop_lock):
with (await self._proc_lock):
# Don't yield control between sending signal & calling wait
# This way, we don't end up in a call to _restart_process_if_needed
# and possibly restarting. We also set _killed, just to be sure.
Expand Down

0 comments on commit 0666875

Please sign in to comment.