F | 尝试在新线程里跑?

This commit is contained in:
shenjack 2023-10-04 16:35:35 +08:00
parent 43a79b3f1c
commit bc42df2472
Signed by: shenjack
GPG Key ID: 7B1134A979775551

View File

@ -189,7 +189,7 @@ async def add_message(data: Dict[str, Any]):
evals: str = data.get('message').get('content')[2:] evals: str = data.get('message').get('content')[2:]
try: try:
result = await asyncio.wait_for(safe_eval(evals), 5) result = await asyncio.gather(asyncio.to_thread(safe_eval, evals))
except asyncio.TimeoutError: except asyncio.TimeoutError:
result = f'{evals}\n超时' result = f'{evals}\n超时'
reply = ReplyMessage(id=data['message']['_id']) reply = ReplyMessage(id=data['message']['_id'])