I’m learning python. I built a bot which parses data from some website every 30 minutes and sends me a message. When I deploy it to Render.com it kinda works but manually sending message doesn’t work. I’m talking about send_new_tweet(channel) function which is not getting executed. When I test it locally it works es expected.
I’m launching the app with gunicorn main:app command.
I marked with # executes pieces of code which I see in the log.
if request.method == ‘POST’:
r = request.get_json()
if ‘message’ in r:
chat_id = r[‘message’][‘chat’][‘id’]
msg = r[‘message’][‘text’]
print(‘private message’, msg)
if ‘/start’ in msg:
send_message(chat_id, ‘working!’, disable_notification=True) # executes
send_new_tweet(channel) # DOES NOT EXECUTE ?
# send_message(channel, ‘test message’)
elif ‘channel_post’ in r:
print(‘channel message received’)
Trying to deploy and it fails for some reason. This is what I see in the log…
Jan 16 04:47:35 PM You should consider upgrading via the ‘pip install --upgrade pip’ command.
Jan 16 04:47:35 PM ==> Generating container image from build. This may take a few minutes…
Jan 16 04:49:09 PM ==> Uploading build…
Jan 16 04:49:30 PM ==> Build uploaded in 16s
Jan 16 04:49:30 PM ==> Build successful
Jan 16 04:49:30 PM ==> Deploying…
So my bot is working now, but for some reason sometimes its not responding. It supposed to print something in the log every 2 minutes but it went quiet for 20 minutes and then restarted.
Why does that happen? Any help is appreciated!
Web Services on the free instance type are automatically spun down after 15 minutes of inactivity. When a new request for a free service comes in, Render spins it up again so it can process the request.