jason810496 commented on code in PR #61281:
URL: https://github.com/apache/airflow/pull/61281#discussion_r2786881307
##########
airflow-core/src/airflow/api_fastapi/main.py:
##########
@@ -23,6 +23,21 @@
# This ensures plugins loaded at import time get the correct secrets backend
chain
os.environ["_AIRFLOW_PROCESS_CONTEXT"] = "server"
+# Defensive: Disable uvloop if PYTHONASYNCIODEBUG=1 is set (see Airflow issue
#61214)
+if os.environ.get("PYTHONASYNCIODEBUG") == "1":
+ import asyncio
+ import warnings
+
+ # Explicitly set the default event loop policy to prevent uvloop from
being used
+ asyncio.set_event_loop_policy(asyncio.DefaultEventLoopPolicy())
+
+ warnings.warn(
+ "PYTHONASYNCIODEBUG=1 detected: uvloop is not compatible with asyncio
debug mode on Python 3.13+. "
+ "Using default asyncio event loop.",
+ RuntimeWarning,
+ stacklevel=2,
+ )
Review Comment:
I'm not sure whether
`asyncio.set_event_loop_policy(asyncio.DefaultEventLoopPolicy())` will prevent
uvloop from being used.
https://docs.python.org/3/library/asyncio-policy.html#asyncio.DefaultEventLoopPolicy
It seems we don't even have the ability to control uvloop, and this might be
out of scope for Airflow. Since the dependency chain is fastapi -> uvicorn ->
uvloop, even bugs in uvloop will also be out of scope for uvicorn, for example:
https://github.com/Kludex/uvicorn/issues/2464#issuecomment-2365198633.
So I think the only thing we can do is add a warning, which should be enough
for users.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]