mirror of
https://github.com/microsoft/autogen.git
synced 2026-02-11 12:05:04 -05:00
make code execution async (#219)
* make code execution async * python 3.10 does not support asyncio.timeout() * make code execution cancellable * make code execution async * python 3.10 does not support asyncio.timeout() * make code execution cancellable * make entire callstack for code_executor async * Update python/src/agnext/components/code_executor/_impl/local_commandline_code_executor.py Co-authored-by: Jack Gerrits <jackgerrits@users.noreply.github.com> * fix variable description * remove unnecessary code * fix usage of execute_code_blocks * fix usage of execute_code_blocks --------- Co-authored-by: Jack Gerrits <jackgerrits@users.noreply.github.com> Co-authored-by: Eric Zhu <ekzhu@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import asyncio
|
||||
import re
|
||||
from typing import List, Optional, Tuple, Union
|
||||
|
||||
@@ -81,11 +80,7 @@ class Executor(BaseAgent):
|
||||
code = self._extract_execution_request(message_content_to_str(message.content))
|
||||
if code is not None:
|
||||
execution_requests = [CodeBlock(code=code, language="python")]
|
||||
future = asyncio.get_event_loop().run_in_executor(
|
||||
None, self._executor.execute_code_blocks, execution_requests
|
||||
)
|
||||
cancellation_token.link_future(future)
|
||||
result = await future
|
||||
result = await self._executor.execute_code_blocks(execution_requests)
|
||||
|
||||
if result.output.strip() == "":
|
||||
# Sometimes agents forget to print(). Remind the to print something
|
||||
|
||||
Reference in New Issue
Block a user