comment out sleep

This commit is contained in:
2026-02-28 10:59:24 +08:00
parent d9a654170c
commit 851284b0a3

View File

@@ -34,13 +34,14 @@ class Calculator(LangToolBase):
def calculator(self, python_expression: str) -> dict:
"""For mathamatical calculation, always use this tool to calculate the result of a python expression. You can use 'math' or 'random' directly, without 'import'."""
# time.sleep(20)
result = eval(python_expression, {"math": math, "random": random})
return {"success": True, "result": result}
async def calculator_async(self, python_expression: str) -> dict:
"""Async version: runs eval in a thread pool to avoid blocking the event loop."""
async with get_semaphore():
await asyncio.sleep(5) # Simulate delay for testing
# await asyncio.sleep(20) # Simulate delay for testing
result = await asyncio.to_thread(
eval, python_expression, {"math": math, "random": random}
)