'How to prevent TIMEOUT for VM?
I tested receiving signals to telegram from google cloud which is very simple code but everytime I tried, it automatically timed-out every 3~4 hours without any error log. If I tried to enter SSH again, it shows I cannot connect server so I need to stop& restart server.
my code is as below.
import random
import time
import telegram
#open file
file_path="1.txt"
with open(file_path, encoding='utf-8-sig') as f:
lines=f.readlines()
lines = [line.replace('\n', ' ') for line in lines]
#telegram setting
bot_token = '5305404279:AAGEUeeR-ru42q8WIk7_44FfchmRNd4joE'
bot = telegram.Bot(token=bot_token)
chat_id = 1575861348
while True:
ran_word = random.sample(lines, 1)
bot.sendMessage(chat_id=chat_id, text=ran_word)
time.sleep(20)
and my command is
nohup python3 1.py &
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|