[KongchangAI]
ConceptPython asyncio / 异步IO

asyncio

An asynchronous I/O framework included in the Python standard library. It is based on a coroutine and single-threaded event loop model, and is used to write concurrent network applications and asynchronous programs.

Core Facts

Timeline (last 90 days)

Nov 3

Python provides an event loop through the asyncio module, and a coroutine defined with async def is only actually scheduled and executed after it is awaited or wrapped as a task.

Unverified50%
Oct 25

Running AgentScope requires the use of asynchronous programming (async/await): conversation methods must be defined with async def, await is used where the model is called, and at startup an asynchronous entry point such as asyncio.run() must be used; it cannot be called directly in a synchronous manner.

Unverified50%
Oct 17

In asyncio, the CancelledError injected by Task.cancel() still triggers finally, but if there is an await inside finally and the cancellation signal arrives again, the release logic may be interrupted.

Unverified50%
Oct 17

To avoid concurrent graph-building races for the same repository, RepoBuddy maintains one `asyncio.Task` per repository protected with `asyncio.shield`, letting all callers share the same build result (request coalescing pattern).

Unverified50%
Oct 17

In an asyncio environment, SQLAlchemy implicit lazy loading triggers the MissingGreenlet error, and it often blows up only when serializing the response.

Unverified50%
Oct 16

Treating async as an infrastructure-layer concern and separating data fetching from business decisions (for example, decide_checkout receiving order and profile parameters rather than fetching them itself) decouples business logic from infrastructure, keeping it testable and reusable.

Unverified50%
Oct 16

A function defined with async def returns a coroutine object that must be driven by an event loop to execute; the await keyword can only be used inside async functions, so once a layer is asynchronous, all synchronous functions that call it must be changed to async (the function coloring problem).

Unverified50%
Oct 14

The streaming playback approach uses asyncio.create_subprocess_exec to start an ffmpeg process, with parameters specifying pipe:0 as input, s16le as the output format, a 48000Hz sample rate, and two channels, and loops reading 1024-byte chunks from the response stream and writing them to ffmpeg's stdin.

Unverified50%
Oct 12

Batch ingestion uses asyncio.Semaphore(10) to limit concurrency, preventing the embedding service from being overwhelmed.

Unverified50%
Oct 12

Python 3.11 introduced the tomllib module for TOML parsing and brought asyncio's TaskGroup and timeout() features as well as the datetime.UTC alias.

Unverified50%

18 more timeline events

All Facts (20)

Verified

PyO3 is a Python binding library for the Rust language that encapsulates the low-level details of the CPython API through Rust's type system and ownership mechanism.

65%
Unverified

Python中处理并发有三种主要范式:多线程(threading)、多进程(multiprocessing)和异步IO(asyncio)

95%
Unverified

Agentica采用async-first(异步优先)架构,基于Python的asyncio生态构建

90%
Unverified

asyncio需要整个调用链都支持async/await,改造成本极高

90%
Unverified

对于等待子进程完成这类IO密集型任务,线程切换的开销远小于收益,多线程比asyncio更适合

80%
Unverified

In Jupyter Notebook or certain framework environments where the event loop is already running, directly calling asyncio.run() will raise a 'This event loop is already running' error; the common fix is to patch it using the nest_asyncio library (nest_asyncio.apply()).

70%
Unverified

Compared to asyncio coroutine solutions, the advantage of threads is that code does not need to be rewritten in async/await style, existing synchronous libraries can be used directly, and the learning curve is gentler.

60%
Unverified

Python's asyncio is a standard library introduced in Python 3.4.

60%
Unverified

Python的asyncio是基于单线程事件循环的协程并发模型,asyncio.gather并非真正的CPU并行,而是I/O并发

60%
Unverified

Python provides an event loop through the asyncio module, and a coroutine defined with async def is only actually scheduled and executed after it is awaited or wrapped as a task.

50%
Unverified

Running AgentScope requires the use of asynchronous programming (async/await): conversation methods must be defined with async def, await is used where the model is called, and at startup an asynchronous entry point such as asyncio.run() must be used; it cannot be called directly in a synchronous manner.

50%
Unverified

In asyncio, the CancelledError injected by Task.cancel() still triggers finally, but if there is an await inside finally and the cancellation signal arrives again, the release logic may be interrupted.

50%
Unverified

To avoid concurrent graph-building races for the same repository, RepoBuddy maintains one `asyncio.Task` per repository protected with `asyncio.shield`, letting all callers share the same build result (request coalescing pattern).

50%
Unverified

In an asyncio environment, SQLAlchemy implicit lazy loading triggers the MissingGreenlet error, and it often blows up only when serializing the response.

50%
Unverified

Treating async as an infrastructure-layer concern and separating data fetching from business decisions (for example, decide_checkout receiving order and profile parameters rather than fetching them itself) decouples business logic from infrastructure, keeping it testable and reusable.

50%
Unverified

A function defined with async def returns a coroutine object that must be driven by an event loop to execute; the await keyword can only be used inside async functions, so once a layer is asynchronous, all synchronous functions that call it must be changed to async (the function coloring problem).

50%
Unverified

The streaming playback approach uses asyncio.create_subprocess_exec to start an ffmpeg process, with parameters specifying pipe:0 as input, s16le as the output format, a 48000Hz sample rate, and two channels, and loops reading 1024-byte chunks from the response stream and writing them to ffmpeg's stdin.

50%
Unverified

Batch ingestion uses asyncio.Semaphore(10) to limit concurrency, preventing the embedding service from being overwhelmed.

50%
Unverified

Python 3.11 introduced the tomllib module for TOML parsing and brought asyncio's TaskGroup and timeout() features as well as the datetime.UTC alias.

50%
Unverified

摄入管线通过计算文档内容的SHA256哈希(取前16位)作为chunk_hash来实现幂等性,批量摄入使用asyncio.Semaphore(10)控制并发。

50%

Source Articles