Skip to content

Commit

Permalink
properly shutdown robot gateway after execution
Browse files Browse the repository at this point in the history
use `finally` block for cleanup actions like shutting down the gateway.
This ensures that the cleanup code runs regardless of whether an
exception was raised.
  • Loading branch information
Anita Caron committed Jun 21, 2024
1 parent ca7061b commit 21095b4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions util/dashboard/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,13 +397,13 @@ def run():

with open(dashboard_yml, 'w+') as f:
yaml.dump(data_yml, f)
gateway.detach(robot_gateway)
except Exception:
logging.exception(f"Creating dashboard for {ontology_file} failed")
try:
gateway.close()
except Exception:
logging.exception("Closing JavaGateway failed")
finally:
try:
gateway.shutdown()
except Exception as e:
logging.exception("Failed to shut down the gateway: %s", e)

sys.exit(0)

Expand Down

0 comments on commit 21095b4

Please sign in to comment.