agentscope-ai / agentscope-ai/QwenPaw
[Bug]: Message queue blocked when _process_batch hangs due to missing timeout protection
- Lingua principale
- Python
- Stelle
- 34.9k
- Fork
- 3.1k
- Merge medio
- 1g 15h
- PR unite (30g)
- 225
Descrizione
## Environment
- CoPaw: 0.0.7
- OS: Windows 11
- Python: 3.x
## Problem Description
When `_process_batch` is executing and the LLM API call hangs (e.g., due to network issues, API timeout, etc.), the entire message queue becomes blocked:
1. `_process_batch` starts executing → `_in_progress = True`
2. LLM API call hangs (no timeout protection)
3. `_in_progress` is never cleared
4. New messages enter `pending` queue and wait
5. All message processing is blocked
### Key Log
\copaw\app\channels\manager.py:230 | 2026-03-17 19:44:08 | manager _enqueue_one dingtalk: key=ZFsk+2A= in_progress=True payload_has_sw=True -> pending copaw
## Root Cause
The `_process_batch` function lacks timeout protection. When the LLM API call hangs, `_in_progress` remains `True` indefinitely, blocking the entire message queue.
## Expected Behavior
- `_process_batch` should have a timeout mechanism
- When timeout occurs, `_in_progress` should be properly cleaned up
- New messages should not be blocked by a hanging previous request
## Suggested Solution
Add timeout protection to `_process_batch`:
```python
async def _process_batch(ch: BaseChannel, batch: List[Any]) -> None:
try:
# Add timeout protection (e.g., 5 minutes)
await asyncio.wait_for(
_process_batch_internal(ch, batch),
timeout=300
)
except asyncio.TimeoutError:
logger.error("_process_batch timeout for channel=%s", ch.channel)
# Ensure _in_progress is cleaned up
except Exception as e:
logger.error("_process_batch error: %s", e)
# Ensure _in_progress is cleaned up
```
## Workaround
Currently, the only workaround is to restart the copaw process:
```python
Stop current copaw
taskkill /F /PID
Restart copaw
copaw run
```
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.