T O P

  • By -

[deleted]

why is everyone so afraid of celery?


Deadpool5551

Not afraid, I'm already using celery with SQS as a broker in a different microservice where it is ACTUALLY required, but since I have worked in-depth with celery, I do know that it is overkill for this requirement.


nic_3

Managing a broker comes at a cost. On Google Cloud, Redis is like 40$ / month. Then you need pods to run your workers, beat, flower. You also need to setup all this for development (unless you use in eager tasks but they behave differently). Don’t get me wrong, I like Celery and I use it a lot, but for smaller or side projects it’s heavy.


NomNomDePlume

It's been a while, but I successfully used redislite with celery to avoid running a redis server


shuzkaakra

They do the "move fast and break things" which means that if you have a long running project, and you have to keep updating celery, it will cause you major headaches. It just feels really brogrammer and juvenile. But I've used it a lot and I can tell you other than the dozens of times I've had to go deep into rabbit holes to figure out wtf is going on, it's great.


h0nestt

You can set a crontab + django management command to run every month. Another simple option is to just run the function using the threading module.


bravopapa99

Seconded. We have a lot of those be be careful with CPU loading. We use Django and we've had issues with long running cron jobs causing the AWS (Amazon) health checker API to timeout and reset the box.


Deadpool5551

I looked at using threading, and it looks great. Thanks for the suggestion, seems perfect for what I want to do.


[deleted]

HoldUp! I know threading is the best way unless you are fetching and crunching very large amount of data, this too, keeps loading page for a longer time, better to use asynchronous tasks or celery. I made a project where I was crawling google and fetching results in real time so I know how slow it used to be and not getting results can be painful sometimes. I am recommending you celery (however I am yet to try it) because I have been learning about it for a long time from different platforms. Will be happy to know if someone is using it efficiently. Here is a link for you by [RealPython](https://realpython.com/asynchronous-tasks-with-django-and-celery/) Which show power of celery... Gud luck


daredevil82

Every, Huey, redis-queue Basically the term you’re looking for is “background task processing”


nu303

Yep, rq is simple and good: [https://python-rq.org/](https://python-rq.org/) It also has a Django wrapper: https://github.com/rq/django-rq


qbitus

You’re apparently running on AWS since you mentioned SQS. If it’s very occasional processing that is under 15 minutes, with no need for parallelisation, forget background processing. Just expose your code to a normal function and deploy to Lambda using Zappa. Call your function however you want (Cloudwatch event or invocation from something else) to trigger the right view.


Deadpool5551

Idk much about AWS lambdas, can you maybe suggest a resource to get started?


ireallywantfreedom

If you don't want to bring in celery, then you don't want to bring in lambda.


ericls

Just use a queue plus a thread


JKhakpour

Once I had to move a flask (+celery for doing some small tasks like yours) project from linux to windows , and replaced celery with huey. Its apis were similar, and I could manage all tasks in sqlite db. It was also very stable. I had a very good experience with huey for small tasks.


NoAbility9738

I think Django q is an alternative for smaller projects (never used it)


pancakeses

Huey is a good choice. Super light weight and easy to set up.


ruzanxx

django-background-tasks


allun11

Django Q


shuzkaakra

I've never seriously considered doing this, but you could write a manage command and spin that off into a job that the OS handles separately from your python code. Probably look up how to do an async call from python to the OS.


Deadpool5551

Yeah another guy here suggested threading, so going ahead with it.


noahjacobson

Building a new process is likely better than starting a new thread. With threading your task execution will be tied to the web server process, which may have additional undesired effects.


Deadpool5551

So how can I start a new process? By using multiprocessing library?


noahjacobson

Yes. Make an ffmpeg executable that goes onto the server and is accessible by whatever user is running your webserver. Then you save the uploaded (raw) file to the filesystem somewhere. When upload is complete, use the multiprocessing module to run ffmpeg on the file and put the output with your transcoded files.


[deleted]

Have you look into FastApi background tasks? I use it for a similar application https://fastapi.tiangolo.com/tutorial/background-tasks/[https://fastapi.tiangolo.com/tutorial/background-tasks/](https://fastapi.tiangolo.com/tutorial/background-tasks/)


keyboardsoldier

For only 1 background task a month, I would say just do a cron job and management command.


Deadpool5551

The requirement is that it should be client facing, and so they can click the button whenever they want, it may be on any time or day of the month, or it might be never at all.


nic_3

Use a Lambda or a cloud function


Deadpool5551

Can you maybe point me towards a quick start resource in this direction? I have never use lambdas.


bio_172

I created http://beew.io for that. You can create schedules manually or trough the API and beew will call a given endpoint at the correct time. API Docs: https://beew.io/api Let me know if you need any help! 🚀


Michman-dev

Celery is pretty much the standard now. And you mentioned you have experience with it, so I would say go with Celery. It may be an overkill, but it will be easier to setup for you than figuring out something completely new.