I have a page where the user selects a Python script, and then this script executes.
My issue is that some scripts take a while to execute (up to 30m) so I’d like to run them in the background while the user can still navigate on the website.
I tried to use Celery but as I’m on Windows I couldn’t do better than using
--pool=solo which, while allowing the user to do something else, can only do so for one user at a time.
I also saw this thread while searching for a solution, but didn’t manage to really understand how it worked nor how to implement it, as well as determine if it was really answering my problem…
So here is my question : how can I have multiple thread/multiple processes on Celery while on Windows ? Or if there’s another way, how can I execute several tasks simultaneously in the background ?
Have you identified whether your slow scripts belong to CPU-bound tasks or I/O bound tasks?
if they’re I/O bound, you can use eventlet and gevent based on Strategy 1 in the blog from distributedpython.com
but if they’re CPU bound, you may have to think of using the ways like a dedicated Celery windows box (or windows Docker container) to workaround Celery billiard issue on Windows by setting the environment variable (
FORKED_BY_MULTIPROCESSING=1) based on Strategy 2 in the blog from distributedpython.com
Answered By – paulyang0125