mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-05 14:55:18 +02:00
add timeout and retry when code execution
This commit is contained in:
parent
fe6e46d478
commit
fd9f2416ff
2 changed files with 54 additions and 12 deletions
|
|
@ -88,3 +88,12 @@ def test_truncate():
|
|||
assert truncate(output) == output
|
||||
output = "hello world"
|
||||
assert truncate(output, 5) == "Truncated to show only the last 5 characters\nworld"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_run_with_timeout():
|
||||
pi = ExecutePyCode(timeout=1)
|
||||
code = "import time; time.sleep(2)"
|
||||
message, success = await pi.run(code)
|
||||
assert not success
|
||||
assert message == "TimeoutError"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue