Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve handler close race condition at triggerer shutdown #37206

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions airflow/utils/log/trigger_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import asyncio
import logging
from contextlib import suppress
from contextvars import ContextVar
from copy import copy
from logging.handlers import QueueHandler
Expand Down Expand Up @@ -110,17 +111,16 @@ def close_one(self, trigger_id):
h = self.handlers.get(trigger_id)
if h:
h.close()
del self.handlers[trigger_id]
with suppress(KeyError): # race condition between `handle` and `close`
del self.handlers[trigger_id]

def flush(self):
for h in self.handlers.values():
h.flush()

def close(self):
for trigger_id in list(self.handlers.keys()):
h = self.handlers[trigger_id]
h.close()
del self.handlers[trigger_id]
self.close_one(trigger_id)


class LocalQueueHandler(QueueHandler):
Expand Down