agentscope.server.async_result_pool module
A pool used to store the async result.
- class agentscope.server.async_result_pool.AsyncResultPool[source]
Bases:
ABC
Interface of Async Result Pool, used to store async results.
- abstract prepare() int [source]
Prepare a slot for the async result.
- Returns:
The key of the async result.
- Return type:
int
- class agentscope.server.async_result_pool.LocalPool(max_len: int, max_expire: int)[source]
Bases:
AsyncResultPool
Local pool for storing results.
- prepare() int [source]
Prepare a slot for the async result.
- Returns:
The key of the async result.
- Return type:
int
- class agentscope.server.async_result_pool.RedisPool(url: str, max_expire: int)[source]
Bases:
AsyncResultPool
Redis pool for storing results.
- INCR_KEY = 'as_obj_id'
- TASK_QUEUE_PREFIX = 'as_task_'
- __init__(url: str, max_expire: int) None [source]
Init redis pool.
- Parameters:
url (str) – The url of the redis server.
max_expire (int) – The max timeout of the result in the pool,
reached (when it is)
removed. (the oldest item will be)
- prepare() int [source]
Prepare a slot for the async result.
- Returns:
The key of the async result.
- Return type:
int
- agentscope.server.async_result_pool.get_pool(pool_type: str = 'local', max_expire: int = 7200, max_len: int = 8192, redis_url: str = 'redis://localhost:6379') AsyncResultPool [source]
Get the pool according to the type.
- Parameters:
pool_type (str) – The type of the pool, can be local or redis, default is local.
max_expire (int) – The max expire time of the result in the pool, when it is reached, the oldest item will be removed.
max_len (int) – The max length of the pool.
redis_url (str) – The address of the redis server.