Forums

always on task help

Hello world,

I am new here as well as new to python. I have a script that sends webhook messages to Discord. If I go to files, click my script, and select run, the script runs successfully;
However even if I have the script in a for loop, after sending messages to Discord, the script will crash. The script always crashes. I've decided to upgrade my account and try the "task always on feature" hoping this will reboot the script when it crashes, as I understand that's a feature.. I simply type the command: python3 /home/user/script.py

"Always on task" takes a while to start up which I've read is normal. Than the task is finally in a 'running state'. However unlike running the task from the files tab, the script never sends messages to Discord. As if the script is not running at all; but Always on task says it is running. If I check the log file the only thing present is 1 line saying: "task preparing to start".

the script is supposed to be printing messages to console as well as sending webhooks to Discord and fails to do either of these things.

Am I not using "Always on task" properly? Do I first run "Always on task" and then run my file from files tab at the same time? Also if I go to dashboard, there is no console running unless I run from files tab.

Here is the help page on how to create always on tasks: https://help.pythonanywhere.com/pages/AlwaysOnTasks/

Glenn,

I have reviewed this page and followed the instructions.

The task is running successfully. My script is not running; I don’t see console anywhere and I am not receiving messages on discord.

It’s not a matter of the script, the script runs and sends me messages on discord but only if I launch from files tab. I have no proof of the script running from always-on task.

I need clearer information as to why this is not working as expected.

Add some logging to your script and then use your always-on task log to debug.

I did not think to do that, thank you

Just to add to that -- check out the page that @glenn linked to previously for some hints on effective logging from always-on tasks, in particular relating to using the "flush" option with print.

Hello, I have the always on task working in running state, still the post request in my flask app crashes after nearly 5 mins and the process stops. Please provide a solution to this issue.

I see I already replied to you in other thread -- let's keep conversation in one place.