agentscope icon indicating copy to clipboard operation
agentscope copied to clipboard

[Feature]: execute python code in thread

Open rayrayraykk opened this issue 1 year ago • 0 comments

The current implementation of exec_python_code is a multi-processing version, which should be in if __name__ == "__main__". We can implement it in the thread and mark it as TODO now.

Update about global var:

# Create a new global namespace dictionary
 global_namespace = {}

 # Copy the contents of the current global namespace into the new namespace dictionary
 global_namespace.update(globals())

 # Execute the provided code within the newly defined global context
 exec(code, global_namespace)

rayrayraykk avatar Mar 25 '24 03:03 rayrayraykk