【问题标题】:Python Daemon / Interprocess CommunicationPython守护进程/进程间通信
【发布时间】:2016-01-12 18:35:00
【问题描述】:

我需要对用户输入的图像执行相当密集的计算。我需要加载几个文件和外部深度学习库才能使其工作,这需要几秒钟才能加载。 此外,这个想法是从 Web 界面获取输入图像,这意味着将同时有多个请求。

我研究了 python 中的守护进程和多处理包,但甚至没有更接近于实现如下所示的基本框架。实现这种要求的正确方法是什么?

load libraries
perform pre-processing steps
wait for input from another python script 
(will eventually be a user uploaded image from web-app)
while (1)
if input received
   process input
   return result
end
end

【问题讨论】:

  • 您应该看看 celery,它是一个用于将任务派生到其他进程甚至机器的框架。 docs.celeryproject.org/en/latest/getting-started/…
  • 谢谢。芹菜看起来确实像我需要的。我只为网络做了有限的编码,并且只使用了 A-M-P。这一切都让我很困惑。我希望我能找到一个使用 celery 的最小功能示例。

标签: python ipc daemon


【解决方案1】:

我想让每个人都知道,我只是使用了cherrypy,并在启动服务器之前完成了所有加载和预处理步骤。我不确定这是否是最好的方法,但到目前为止它正在工作。

【讨论】:

    猜你喜欢
    • 2011-10-06
    • 2023-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-21
    • 1970-01-01
    • 2018-05-14
    • 1970-01-01
    相关资源
    最近更新 更多