Skip to content

Commit

Permalink
catch sentry flush if exception happens in _execute_in_fork finally b…
Browse files Browse the repository at this point in the history
…lock (apache#40060)

* feat(providers/celery): catch sentry flush exception in _execute_in_fork

* feat(providers/celery): add logging.shutdown into finally block
  • Loading branch information
Lee-W authored and romsharon98 committed Jul 26, 2024
1 parent e207e5a commit c3603f4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions airflow/providers/celery/executors/celery_executor_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,12 @@ def _execute_in_fork(command_to_exec: CommandType, celery_task_id: str | None =
log.exception("[%s] Failed to execute task.", celery_task_id)
ret = 1
finally:
Sentry.flush()
logging.shutdown()
try:
Sentry.flush()
logging.shutdown()
except Exception:
log.exception("[%s] Failed to clean up.", celery_task_id)
ret = 1
os._exit(ret)


Expand Down

0 comments on commit c3603f4

Please sign in to comment.