You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PR #61417 with upgrading Ruff version to 0.15.0 enabled rule ASYNC240 per default. Some occurrences and findings make the code not compatible.
Nevertheless the rule seems to make sense in general not blocking async code by IO requests.
What you think should happen instead?
Rule should be re-enabled and code locations should be optimized.
NOTE: It is to be decided which of the two libraries to use and it seems this is adding a new dependency. So a short cal to maintainers is needed to get a quorum which to pick.
Hi! I’m a beginner contributor and very interested in working on this issue as well. I’m happy to collaborate or take on part of the ASYNC240 fixes (e.g. identifying affected files or preparing patches/tests). Please let me know how you’d like to proceed.
Hi @jscheffl I’d like to work on this. I’ve looked into the ASYNC240 rule and the discussion regarding the dependency quorum for Airflow 3.
The issue is that pathlib methods like .exists() and .is_file() are synchronous and block the event loop when called inside async functions. To re-enable the rule, we need to offload these calls to a thread or use an async filesystem wrapper.
Regarding the library choice mentioned in the description:
AnyIO: We could use anyio.to_thread.run_sync to wrap the pathlib calls. This is a surgical fix that doesn't require a full filesystem refactor.
Trio/Aiofiles: These provide native async path objects but would add a more significant dependency for the core.
I’m happy to implement whichever approach the maintainers prefer to get this rule re-enabled.
Agreed — this probably needs a maintainer call before locking in an approach. From my side, I don’t have a strong preference yet and would follow whatever direction the core team recommends.
That said, if a low-risk default is helpful for discussion: anyio.to_thread.run_sync feels like the smallest surface-area change to unblock ASYNC240 without introducing a new async filesystem abstraction. But I’m very happy to wait for guidance from @potiuk, @ashb, @dstandish, or @dabla before moving forward.
I now had time to look to trio and anyio. I think both are valid but anyio seems to be a bit stronger maintained. If nobody has another opinion in the next 24 hours I'd propose to go with anyio. Anyio has less dependencies.
Activity
js0547 commentedon Feb 4, 2026
@jscheffl I’d like to pick this up as a first contribution if that’s okay.
sawantbandita commentedon Feb 4, 2026
Hi! I’m a beginner contributor and very interested in working on this issue as well. I’m happy to collaborate or take on part of the ASYNC240 fixes (e.g. identifying affected files or preparing patches/tests). Please let me know how you’d like to proceed.
v4xsh commentedon Feb 4, 2026
Hi @jscheffl I’d like to work on this. I’ve looked into the
ASYNC240rule and the discussion regarding the dependency quorum for Airflow 3.The issue is that
pathlibmethods like.exists()and.is_file()are synchronous and block the event loop when called insideasyncfunctions. To re-enable the rule, we need to offload these calls to a thread or use an async filesystem wrapper.Regarding the library choice mentioned in the description:
anyio.to_thread.run_syncto wrap thepathlibcalls. This is a surgical fix that doesn't require a full filesystem refactor.I’m happy to implement whichever approach the maintainers prefer to get this rule re-enabled.
jscheffl commentedon Feb 4, 2026
Thanks for the analysis. I am not a deep enought asyncio expert. Any opinions from other experts? @potiuk @ashb @dstandish @dabla ??
v4xsh commentedon Feb 5, 2026
Thanks for the feedback!
Agreed — this probably needs a maintainer call before locking in an approach. From my side, I don’t have a strong preference yet and would follow whatever direction the core team recommends.
That said, if a low-risk default is helpful for discussion:
anyio.to_thread.run_syncfeels like the smallest surface-area change to unblock ASYNC240 without introducing a new async filesystem abstraction. But I’m very happy to wait for guidance from @potiuk, @ashb, @dstandish, or @dabla before moving forward.Let me know how you’d like to proceed.
jscheffl commentedon Feb 5, 2026
I now had time to look to
trioandanyio. I think both are valid but anyio seems to be a bit stronger maintained. If nobody has another opinion in the next 24 hours I'd propose to go with anyio. Anyio has less dependencies.Other opinions welcome!
Fix ASYNC240: replace blocking filesystem calls in async functions wi…
Fix ASYNC240: replace blocking filesystem calls with anyio (#61616)
Fix ASYNC240: replace blocking filesystem calls with anyio (apache#61616
Fix ASYNC240: replace blocking filesystem calls with anyio (apache#61616
Fix ASYNC240: replace blocking filesystem calls with anyio (apache#61616
Fix ASYNC240: replace blocking filesystem calls with anyio (apache#61616
Fix ASYNC240: replace blocking filesystem calls with anyio (apache#61616
Fix ASYNC240: replace blocking filesystem calls with anyio (apache#61616
Fix ASYNC240: replace blocking filesystem calls with anyio (apache#61616
Fix ASYNC240: replace blocking filesystem calls with anyio (apache#61616