Python asyncio Advanced/Know the file I/O caveat

Document the limitation around file descriptor watching for ordinary file I/O.

Section: Migration and Platform Notes

Know the file I/O caveat

python
python
# asyncio can monitor sockets and many OS handles, but regular file I/O
# is not made non-blocking just by using asyncio. Use threads or subprocesses
# for blocking file operations when needed.
Explanation

Asyncio is primarily designed for network I/O and subprocess orchestration; ordinary file reads and writes can still block.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Migration and Platform Notes
Prefer `get_running_loop()` in async code
Modern replacement for older loop access patterns.
OpenIn sheetpythonsame section
Schedule a callback later
Run a plain callback after a delay.
Schedule from another thread
Use `call_soon_threadsafe()` when another thread must notify the loop.
Submit a coroutine from another thread
Use `run_coroutine_threadsafe()` with a loop reference.