3849257: Async creation of thumbnails with RQ

Added 4 years ago by Peter Bengtsson


6 Add your love!



So I have a function called make_thumbnail(filepath, width, extension, save_root) and it's using PIL to create a thumbnail. It's nice that it's a perfectly standalone simple python function.

RQ is a great queue solution which I recommend you check out. You simply use job = q.enqueue(function, arg1, arg2, argN) and the job instance won't have a result for a little while. Until you wait.

This code is extracted from a slightly more complex one but it's simplified to demonstrate a great pattern IMHO.

File: handlers.py