Search code examples
pythondjangoserverweb-development-server

Is there any way to keep tasks running on server side in django?


Basically i have a bot in my django webapp when given your social media credentials it manages your one of social media accounts i was able to succesfully run it while the client is still on website and as you would expect it stopped when the client closed the website. Is there any way to store the credentials and then keep the bot running even after user leaves website and so that bot still manages the account? The bot is mostly making few requests and API calls. Thank You


Solution

  • Lots of options.

    • Celery. A library for organizing a task queue. Production-ready, widely supported, has a great community.
    • Dramatiq possibly with periodic. Dramatiq is also a library for organizing a task queue, periodic is a task scheduler. Less popular, more lightweight, and quite stable. Entry threshold is lesser than celery, as for me.
    • Supervisor. Supervisor is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems. One command to install, very easy to configure, quite suitable for small projects (it's harder to use it when the amount of background routines becomes 10+).
    • Tmux. It is a terminal multiplexer with the possibility to remain a process running after disconnection of it. Could be useful when you're running something one time or for tests.
    • Django Background Task. It is a databased-backed work queue for Django, loosely based around Ruby’s DelayedJob library. Unmaintained and incompatible with Django versions newer than 2.2.