Skip to content

Commit

Permalink
Fix flake8 errors in astrality.py
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobGM committed Apr 8, 2018
1 parent 249c1a9 commit 90424c2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions astrality/astrality.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def exit_handler(signal=None, frame=None) -> None:
1: An empty directory uses neglible disk space.
2: If this process is interrupted by another Astrality instance,
we might experience race conditions when the exit handler deletes
the temporary directory *after* the new Astrality instance creates it.
the temporary directory *after* the new Astrality instance creates
it.
"""

logger.critical('Astrality was interrupted')
logger.info('Cleaning up temporary files before exiting...')

Expand Down Expand Up @@ -110,6 +110,7 @@ def exit_handler(signal=None, frame=None) -> None:
except KeyboardInterrupt: # pragma: no cover
exit_handler()


def other_astrality_pids() -> Set[int]:
"""Return the process ids (PIDs) of any other Astrality instances."""

Expand All @@ -128,15 +129,16 @@ def other_astrality_pids() -> Set[int]:

def kill_old_astrality_processes() -> None:
"""Kill all other instances of this script, to prevent duplicates."""

pids = other_astrality_pids()
failed_exits = 0
for pid in pids:
try:
logger.info(f'Killing duplicate Astrality process with pid {pid}.')
os.kill(pid, signal.SIGTERM)
except OSError:
logger.error(f'Could not kill old instance of astrality with pid {pid}.')
logger.error(
f'Could not kill old instance of astrality with pid {pid}.'
)
logger.error('Continuing anyway...')
failed_exits += 1

Expand Down

0 comments on commit 90424c2

Please sign in to comment.