Skip to content

Commit

Permalink
Merge pull request #23 from cmaneth/feature/shutdown_with_local_conne…
Browse files Browse the repository at this point in the history
…ction

fix shutdown with local connection
  • Loading branch information
Deleh authored Nov 27, 2024
2 parents 37ea3ea + a259a54 commit 2a42265
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions robmuxinator/robmuxinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,12 @@ def shutdown_system(hosts, timeout=60):
logger.info("shutting down hosts:")

# remove own host pc from list
hosts_c = {key: value for key, value in hosts.items() if value.get_hostname() != socket.gethostname()}
def is_own_host(host: Host) -> bool:
if host.get_hostname() in ["localhost", "127.0.0.1", socket.gethostname()]:
return True
return False

hosts_c = {key: value for key, value in hosts.items() if not is_own_host(value)}
if hosts_c:
# concurrently shutdown all other hosts
with ThreadPoolExecutor(max_workers=len(hosts_c)) as executor:
Expand All @@ -642,7 +647,7 @@ def shutdown_system(hosts, timeout=60):
# shutdown own host
host = None
for value in hosts.values():
if value.get_hostname() == socket.gethostname():
if is_own_host(value):
host = value
if host:
host.shutdown(timeout=timeout)
Expand Down

0 comments on commit 2a42265

Please sign in to comment.