Skip to content

Commit

Permalink
fix: ensure no exceptions are passed to session logger.exception sinc…
Browse files Browse the repository at this point in the history
…e filter currently breaks on them
  • Loading branch information
epmog authored and gahyusuh committed Aug 30, 2023
1 parent c6e549d commit e7e0055
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,42 +117,26 @@ def _on_done(
session : Session
The session that the aciton is running in
"""
action_status: ActionStatus = ActionStatus(state=ActionState.SUCCESS)
try:
future.result()
except (FutureCancelledError, AssetSyncCancelledError):
session.update_action(
action_status=ActionStatus(
state=ActionState.CANCELED,
fail_message="Canceled",
),
)
except AssetSyncError as e:
# Already logged to the session log.
# We need to directly complete the action. Other actions rely on the OpenJobIO session's
# callback to complete the action
session.update_action(
action_status=ActionStatus(
state=ActionState.FAILED,
fail_message=str(e),
),
action_status = ActionStatus(
state=ActionState.CANCELED,
fail_message="Canceled",
)
except Exception as e:
session.logger.exception(e)

# We need to directly complete the action. Other actions rely on the OpenJobIO session's
# callback to complete the action
session.update_action(
action_status=ActionStatus(
state=ActionState.FAILED,
fail_message=str(e),
),
action_status = ActionStatus(
state=ActionState.FAILED,
fail_message=str(e),
)
else:
finally:
# We need to directly complete the action. Other actions rely on the OpenJobIO session's
# callback to complete the action
session.update_action(
action_status=ActionStatus(state=ActionState.SUCCESS),
)
session.update_action(action_status=action_status)

def human_readable(self) -> str:
return "job.sync_input_job_attachments()"
Expand Down
5 changes: 2 additions & 3 deletions src/deadline_worker_agent/sessions/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,8 @@ def run(self) -> None:
try:
self._cleanup()
except Exception as error:
logger.exception(error)
logger.error(
"Unexpected exception while performing cleanup of Session %s.", self._id
logger.exception(
f"Unexpected exception while performing cleanup of Session {self._id}: {error}."
)
finally:
self._stopped_running.set()
Expand Down

0 comments on commit e7e0055

Please sign in to comment.