News for hackers. Stuff that matters.
Re:Eighteen months of Django by tomkinstinch on Tuesday May 07, 2013 @08:40PM (#5671805)
I'll add that if you need to background anything, django-celery makes it easy.

celeryd is also good for scheduling tasks with either single or periodic execution.

http://docs.celeryproject.org/en/latest/getting-started/firs...

You can also use it in a typical task queue role. It will pickle or serialize the Python objects that accompany tasks for transmission over the wire.

Re:Eighteen months of Django by wahnfrieden on Tuesday May 07, 2013 @10:53PM (#5672229)
We've had a lot of luck just using gunicorn with a post_response hook for doing some extra work without making the client wait on it before getting a response. It avoids adding another dependency and is pretty straightforward. It makes sense for us since we don't have HUGE tasks that need to be queued, but some things that can take a maybe 0.5 to 3 seconds and where the HTTP response can be sent back before doing this work. I should open source this at some point, it's a small amount of code but pretty handy.
Re:Eighteen months of Django by obviouslygreen on Tuesday May 07, 2013 @08:50PM (#5671835)
Note that periodic execution, one of the more useful aspects of celery, is not supported on all backends. If you're using rabbitMQ, you're golden. If you're using most or all other transports (including SQS), you're likely SOL and will have to resort to either bare cron jobs or something like django-cronograph that accomplishes the same thing.

celery is definitely nice, but it does have its limitations (like everything else).

Re:Eighteen months of Django by hiddentaco on Tuesday May 07, 2013 @10:07PM (#5672095)
I'm really interested in peoples opinion on Celery vs Others when using Django.

I'm about to hit a point in my pet project where I need something but I havn't chosen my approach yet. I've ehard Pyres is better than Celery.

Re:Eighteen months of Django by obviouslygreen on Tuesday May 07, 2013 @10:17PM (#5672131)
Once you wrap your head around one (embarrassingly, it took me a while to really understand what celery was doing -- I had an easier time getting comfortable with the multiprocessing library), it shouldn't be difficult to pick up another and compare them locally.

Celery does what it's supposed to; that's about all I can say for it. I'd suggest writing a few simple jobs and testing them in similar environments under as much load as you can. Look for things like consistency of logging and running tasks exactly once across multiple consumers despite the semantics of the queue you pick.

Re:Eighteen months of Django by crdoconnor on Tuesday May 07, 2013 @11:12PM (#5672264)
This is good to know. I've just started using it with redis.

I never really saw the point of that part of celery anyway. Cron's perfectly adequate on its own (and installed just about everywhere).

Re:Eighteen months of Django by obviouslygreen on Tuesday May 07, 2013 @11:58PM (#5672412)
The nice thing about it from our point of view is the ability to keep everything in source control. Granted, you can keep your cron jobs as scripts, but celery+rabbitMQ allows you to keep it all in Python without the extra deployment step. It's not a huge deal, but it does help a bit with maintainability and getting new devs up to speed.
Re:Eighteen months of Django by crdoconnor on Wednesday May 08, 2013 @02:00AM (#5672777)
We keep all the deployment stuff in source control anyway. For me, it would just mean shifting it from being declared by salt in the "infrastructure" folder to being written in python in the django folder.

I agree that you should keep the code itself in python, but that can be handled just by making it a management command that gets called by cron.

Sysadmins understand and love cron, too. I think celery reinventing the wheel might make some of them a bit mad.

Re:Eighteen months of Django by ludwigvan on Wednesday May 08, 2013 @06:37AM (#5673434)
I'm using cron instead of celery daemon for those tasks, but here are two advantages:

- being able to modify the task frequency from the admin

- cron needs special care with setting the environment variables like PATH

Re:Eighteen months of Django by dangoldin on Wednesday May 08, 2013 @09:34AM (#5674006)
Yea - that's going to be one of the packages I mention in the follow up. I ended up using RabbitMQ as the backend for it which wasn't that easy to setup so I am curious to see what others are using.
Re:Eighteen months of Django by olavgg on Wednesday May 08, 2013 @03:36AM (#5673008)
What about http://pythonhosted.org/APScheduler/ ? Celery is for more massive, high capacity solutions.
Re:Eighteen months of Django by thejosh on Tuesday May 07, 2013 @11:00PM (#5672241)
Using celery for the first time, coming from PHP-land, blew my mind.

Python is now my language of choice for "getting shit done".

Re:Eighteen months of Django by crdoconnor on Tuesday May 07, 2013 @11:19PM (#5672290)
Returning to PHP land afterwards feels like you're taping your code together with duct tape and bits of string.
Re:Eighteen months of Django by ceol on Wednesday May 08, 2013 @02:20AM (#5672829)
At the risk of this becoming a "bash PHP" thread, that's exactly how I feel. Unless I'm doing something very simple, it's always easier, cleaner, and simpler to do it in Python. Even building a basic CRUD app is night and day between the two languages; Django is beautiful and intuitive, while the PHP frameworks come close but have a few snags that make working with them frustrating.

I write this not to meaninglessly bash PHP but to hopefully convince even a single developer passing by to try out Python. I thought the same thing as you, passer-by dev, once: "Why do I need Python? It's stupid. It uses whitespace weirdly. I can do whatever I need in PHP." But then you realize you could be doing everything you're doing in PHP... better, smarter, and faster.

Re:Eighteen months of Django by lmm on Wednesday May 08, 2013 @06:55AM (#5673473)
I'm getting the same feeling now that I have to work in python/django after having used scala. So it's always worth trying new languages, even when you've found one that seems great at the time.
Re:Eighteen months of Django by camus on Wednesday May 08, 2013 @06:38AM (#5673438)
The fact is PHP has excellent frameworks. I tried Django and Flask , and love them. But for now , i'm sticking to PHP( to much legacy code to port ). For new projects ? sure. The only thing which is a bit more complicated with serverside python is deployment on client servers, the rest ( development , testing ), is easier than PHP. I only wished Python had type hinting for functions and methods like PHP does though. Aside from these issues , Python is perfect,more consice and have awesome stuffs like decorators. And a whole lot of awesome libraries.