Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timeout at notify_ifttt #839

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion plotmanager/library/utilities/notifications.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

def _send_notifications(title, body, settings):
if settings.get('notify_discord') is True:
import discord_notify
Expand All @@ -20,7 +22,12 @@ def _send_notifications(title, body, settings):

if settings.get('notify_ifttt') is True:
import requests
requests.post(settings.get('ifttt_webhook_url'), data={'value1': title, 'value2': body})
try:
requests.post(settings.get('ifttt_webhook_url'), data={'value1': title, 'value2': body}, timeout=10)
except requests.exceptions.Timeout:
logging.error(f"Connecting to IFTTT timeout.(Default is 10 sec)")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timeout doesn't necessarily mean Connection timeout as request doc mentions it catches both
requests.exceptions.ConnectTimeout , requests.exceptions.ReadTimeout errors.

except requests.exceptions.RequestException as e:
logging.error(f"Fail to connect IFTTT-{str(e)}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is also misleadning. this can be anything, failed to connect is only 1 case of many.



def send_notifications(title, body, settings):
Expand Down