Skip to content

Commit c0a4bca

Browse files
address review
1 parent 825b4eb commit c0a4bca

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

Doc/library/asyncio-threading.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ Since Python 3.14, asyncio has first-class support for free-threaded
2020
Python, and the implementation of asyncio is safe to use in a
2121
multi-threaded environment.
2222

23-
Combining asyncio with threads is most useful when you want to scale
24-
I/O-bound work across multiple CPU cores by running an event loop per
25-
thread, or when you need to run blocking or CPU bound code from an
23+
A single event loop on one core can handle many connections
24+
concurrently, but the Python code that runs to handle each one still
25+
executes serially. Once requests involve a non-trivial amount of
26+
per-request computation, that handling becomes the bottleneck, and a
27+
single core can no longer keep up. Combining asyncio with threads is
28+
most useful here: by running an event loop per thread, the handling of
29+
different requests can run in parallel across multiple CPU cores. It is
30+
also useful when you need to run blocking or CPU-bound code from an
2631
asyncio application.
2732

2833

0 commit comments

Comments
 (0)