Skip to content

Commit

Permalink
🎨♻ Specifically check for PID creation time
Browse files Browse the repository at this point in the history
  • Loading branch information
webknjaz committed Mar 21, 2021
1 parent 6f589c4 commit 3589148
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions magicbus/plugins/opsys.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,20 @@ def join(self, timeout=None, poll_interval=0.1):
except OSError: # file does not exist
return

initial_creation_time = initial_stat.st_ctime

starttime = time.time()
while timeout is None or time.time() - starttime <= timeout:
try:
if initial_stat != os.stat(self.pidfile):
return # file has been changed/replaced
pid_stat = os.stat(self.pidfile)
except OSError:
return # file does not exist

pid_creation_time = pid_stat.st_ctime
if pid_creation_time > initial_creation_time:
return # file has been replaced

if pid_stat != initial_stat:
return # file has been changed

time.sleep(poll_interval)

0 comments on commit 3589148

Please sign in to comment.