Skip to content

Commit

Permalink
Properly shutdown robot gateway after execution (#125)
Browse files Browse the repository at this point in the history
* properly shutdown robot gateway after execution

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.

* enable `gateway.shutdown` to log exception in case of error

Need to add the `raise_exception` parameter to the `gateway.shutdown`
method to allow the caller to specify if an exception should be raised
in case of error. The default value is `False`.

---------

Co-authored-by: Anita Caron <[email protected]>
Co-authored-by: Anita Caron <[email protected]>
  • Loading branch information
3 people authored Jun 24, 2024
1 parent 64255c2 commit e39cde9
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(raise_exception=True)
except Exception as e:
logging.exception("Failed to shut down the gateway: %s", e)

sys.exit(0)

Expand Down

0 comments on commit e39cde9

Please sign in to comment.