As @ianbuywise says, anvil.server.wait_forever()
will keep the script running.
However, if you want the script to restart after a crash/reboot/whatever then here’s one technique.
Have a cron job that runs every 2 minutes (or whatever period of time works for you) that starts the uplink script. Then protect your script from running multiple times by using a library like :
The docs explain how to use it, but here’s a snippet from my app :
from pid.decorator import pidfile
...
@pidfile()
def start_app():
...
if __name__ == "__main__":
try:
start_app()
except PidFileError:
print("Already running!")
This is for Linux, but I imagine it would work on Windows (though you’d use the task scheduler rather that cron).