Forums

console stop running code and reset

Hello,

I am trying to run a python script that should run 24/7 (something to update my trading bots based on telegram signals), but it seems that every time I run the code via the console about 24h later the script runs no more and the console has rebooted (so no way to see what happened).

Anyone can help on this ? If anyone from pythonanywhere reads this its the console named 3cqsbot. Also, I am on the 5$/month plan.

Thanks in advance

We do not keep consoles running forever. If you want a task to run continuously, use an always on task.

Hi Glenn,

Thanks for the help. I tried to run the script via the always-on tasks but it leads me to another problem. The script I want to run is using other files in the same folder and it seems that when I run the command:

python3.9 /home/arnoberto/3cqs/3cqsbot.py

it is not able to find the other files needed in the script that are located in the same folder (3cqs). Can you help on this ?

Thanks

If it's a matter of accessing files, try using absolute paths.

It seems to have worked thanks.

I am facing another problem now because the script needs input from the console at the beginning and seems impossible in an always-on taks.

Or alternatively is it possible to run a command in a console via the always-on tasks instead of just a script ? If yes what would be the command in the always-on task please ?

I'm not entirely sure what you're trying to do, because I'd guess that idea of a task that runs non-stop excludes the use of interactivity. I'd say -- if you need to process some input, you maybe need a web app integrated to an always-on task, like in this blog post?

I'll explain how my script works:

  1. script start
  2. script ask for my phone number, I type it in the console.
  3. script asks for the Telegram code I received, I type it in the console.
  4. script runs indefinetely waiting for some Telegram channel signals while updating my trading bots.

So when I launch the scrpit through the always on task there is no interaction with console and the script just indefintely asks for my phone number which I cannot type. Hope its understandable.

Yes, it is. That kind of script will not work in an always on task. If you need to pass information into the task, you will need to provide it either as an argument to the script or through a file that the script reads.

Yes I already thought about it, but the nature of the process makes this difficult to implement because after the scripts ask for your phone number, it will send a request to Telegram and only after this you receive the confirmation code on your phone.. So you cannot implement this input in the code before running it.

Maybe you can do it in the web app, possibly combining it with an always-on task.