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

Mute 3.12.2 error #13831

Merged
merged 3 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/prefect/logging/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ def flush(cls):
)

# Not ideal, but this method is called by the stdlib and cannot return a
# coroutine so we just schedule the drain in a new thread and continue
from_sync.call_soon_in_new_thread(create_call(APILogWorker.drain_all))
# coroutine so we just schedule the drain in the global loop thread and continue
from_sync.call_soon_in_loop_thread(create_call(APILogWorker.drain_all))
return None
else:
# We set a timeout of 5s because we don't want to block forever if the worker
Expand Down
13 changes: 12 additions & 1 deletion src/prefect/server/models/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,18 @@ async def create_logs(
Returns:
None
"""
await session.execute(db.insert(db.Log).values([log.model_dump() for log in logs]))
try:
await session.execute(
db.insert(db.Log).values([log.model_dump() for log in logs])
)
except RuntimeError as exc:
if "can't create new thread at interpreter shutdown" in str(exc):
# Background logs sometimes fail to write when the interpreter is shutting down.
# This is a known issue in Python 3.12.2 that can be ignored and is fixed in Python 3.12.3.
# see e.g. https://github.com/python/cpython/issues/113964
pass
else:
raise


@inject_db
Expand Down