【问题标题】:Python concurrent.futures threadpoolexecutor thread managementPython concurrent.futures threadpoolexecutor 线程管理
【发布时间】:2022-01-10 14:02:42
【问题描述】:

我有一个 FastAPI 应用程序,它有一个需要并行运行一些任务的 API。我已经实现了 threadpoolexecutor 并且工作正常。唯一的问题是每次请求到达该 API 并执行到线程池执行程序时,它都会创建新线程而不是使用旧线程。完成执行后,线程仍然存在并处于空闲状态。他们没有关闭。

【问题讨论】:

  • 请提供足够的代码,以便其他人更好地理解或重现问题。

标签: python fastapi threadpoolexecutor concurrent.futures


【解决方案1】:

问题现已解决。 问题是在 init 中我调用了 playwright.start() 方法,该方法启动了一些连接,但在拆卸时没有调用 stop 方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-02
    • 1970-01-01
    • 1970-01-01
    • 2018-05-09
    • 1970-01-01
    • 2020-10-09
    相关资源
    最近更新 更多