Always-on tasks

Always-on tasks are a new feature we rolled out in our last system update. Essentially, they're a way you can specify a program and tell us that you want us to keep it running all the time. If it exits for any reason, we'll automatically restart it -- and even in extreme circumstances, for instance if the server that it's running on has a hardware failure, it will fail over to a working machine quickly.

We already have that kind of availability for websites, of course -- always-on tasks are a way of providing the same kind of uptime for non-website scripts, so they're the right solution if you want a non-website program that runs 24/7 -- for example, a chat bot on Twitter or Discord, or something that streams data from an external source. All paid accounts get one always-on task by default, and you can customize your account to add more if you need them.

If you have a paid account and would like to try them out, we have detailed documentation here.

We added them because a lot of people want to run something all the time, and would try doing that in a console -- this works, and we keep consoles running for as long as we can, but they do need to be rebooted from time to time for system maintenance, and when that happens, your programs stop running.
Historically we'd advised people to set up a scheduled task to run their script, with some locking code to make sure that only one copy was running at a time -- but this was not ideal, as if the program crashed, it could be some time before it was restarted.

The one thing you can't do with always-on tasks right now is use them to run a server; we have plans to address that in the future, but we don't have any timelines yet. Do let us know if that's something you'd be interested in -- say, running Celery or even an async website in a task. The more people that ask for it, the higher up our priority list it goes :-)

blog comments powered by Disqus

PythonAnywhere is a Python development and hosting environment that displays in your web browser and runs on our servers. They're already set up with everything you need. It's easy to use, fast, and powerful. There's even a useful free plan.

You can sign up here.