简体   繁体   English

Python:Celery,我怎样才能让它在后台运行?

[英]Python : Celery, How can I make it run in background?

I use celery, with python 3 and supervisor in Ubuntu. 我在Ubuntu中使用celery,python 3和supervisor。

I've been working to make a new API, which will get an image from the internet using PIL(Pillow) and save it in a server. 我一直在努力制作一个新的API,它将使用PIL(Pillow)从互联网上获取图像并将其保存在服务器中。

However the problem is that I use Celery as scheduler and in the original API it returns the result in a milisecond, but when I use PIL, the wait becomes almost a second. 然而问题是我使用Celery作为调度程序,并且在原始API中它以毫秒为单位返回结果,但是当我使用PIL时,等待几乎变成了一秒。

So as a solution, I am looking for a way to make the Celery worker run in the background. 所以作为一个解决方案,我正在寻找一种让Celery工作者在后台运行的方法。

Is it possible? 可能吗?

What you probably want is to daemonize your Celery worker. 您可能想要的是为您的Celery工作人员守护

If you follow the steps provided in the Celery running the worker as a daemon documentation you will be able to do that. 如果您按照Celery中提供的步骤运行worker作为守护程序文档,您将能够执行此操作。

It is a bit of a complicated process, but it will allow the Celery worker to run in the background 这是一个复杂的过程,但它将允许Celery工作者在后台运行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM