0
您可以看到完整的here。如何取消使用`concurrent.futures.ProcessPoolExecutor`运行的长时间运行的子进程?
我的代码的简化版本如下:
executor = ProcessPoolExecutor(10)
try:
coro = bot.loop.run_in_executor(executor, processUserInput, userInput)
result = await asyncio.wait_for(coro, timeout=10.0, loop=bot.loop)
except asyncio.TimeoutError:
result="Operation took longer than 10 seconds. Aborted."
不幸的是,当一个操作超时,该进程仍在运行,即使未来已经被取消。我如何取消该流程/任务以使其实际停止运行?