简体   繁体   中英

How do I keep Google cloud VM instance running for hours?

So, I have written a python script on Windows that uploads 1000s of images to a website with additional data and steps. It uses pyautogui, pickle, random and os libraries. And I want to run it on google cloud and don't want my device to be turned on that long. Script should run approximately for 30 hours non-stop. And I need to have gui, keyboard and everything up 'cause the script locates screenshots of buttons and fields then clicks or writes. Basically I want that script to run for ~30 hours under the same conditions as when I'm on, but without me logged in. How do I do that?

You could use pythonw.exe to run your script. Here you can find a very good explanation on how it works and when to use it 1 .

"As per Python documentation:

  1. python.exe is associated with.py files and runs in python terminal.

  2. pythonw.exe is associated with.pyw files and does not run in the terminal. It is for a GUI program.

  3. When python.exe runs the program, a black console window (also called the command line window, DOS / CMD window) will pop up.

  4. pythonw.exe is a windowless Python executable program, which means that when running the program, there is no window and the code is executed in the background.

The difference between.py and.pyw files also comes from the difference between python.exe and pythonw.exe. When installing Python for Windows, Files with a.py extension are defaulted to run with python.exe, and.pyw files are defaulted to run with pythonw.exe.

The.pyw format is designed to run pure graphical interface programs that are developed. Users of pure graphical interface programs do not need to see the console window. When developing a program with a pure graphical interface, you can temporarily change.pyw to.py, and the console window can be called up at runtime to easily see all error messages."

You can take a look at the official documentation for more information here: 2 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM