Forums

Realtime communication between tasks without web apps

I have various scheduled tasks that need to run daily at specific times. Unfortunately, the tasks need to communicate with each other. This means task A needs to trigger a specific code snippet in task B, which triggers (once completed successfully) a code in task C and so on. Is there any way to implement something like this on PythonAnywhere, but in real-time (i.e., without polling) and without using web apps? The problem with web apps is that I need many different such tasks (which would of course become very expensive), I also don't want the tasks to run continuously but to certain times like scheduled tasks, and I also don't want/need any public URL for this. On my local machine it perfectly works with flask and localhost 5000, but I guess this won't work at pythonanywhere without subscribing for dozens of web apps. The problem with polling is that there is either a lack of accuracy/latency time or I would waste huge amounts of cpu time for nothing. Many thanks in advance!

If you want to use only scheduled tasks, you could try with keeping the state in a database maybe? You would still need some kind of "polling" in the task, i.e. a loop with checking for a condition in the database and a sleep. Mind that scheduled tasks on a paid account can run up to 12h, but no longer.