首页 > 解决方案 > 无法在使用 gunicorn 预加载标志运行的烧瓶应用程序中使用 threadpoolexecutor

问题描述

我有一个烧瓶应用程序,我正试图用 gunicorn 放在前面。我想使用预加载标志,因为我的应用程序有一些使用 apscheduler 的计划作业,我只想在主服务器而不是工作人员中运行。

我还想在 python 中使用 ThreadPoolExecutor 将作业委托给由我的应用程序上的路由触发的后台。

当我将 --preload 标志与 gunicorn 一起使用时,对我的 threadpoolexecutor(使用 executor.submit)的任何调用似乎都失败了。当我通过 apscheduler 以编程方式触发作业时,似乎也会发生同样的情况。

当我不使用 --preload 标志时,一切运行顺利。

是否有一些配置我可以更改以使其正常工作,或者这不适用于 --preload 标志?

标签: pythonflaskboto3gunicorn

解决方案


推荐阅读