Skip to content

Add timeout at notify_ifttt#839

Open
r1235613 wants to merge 1 commit intoswar:mainfrom
r1235613:fix_ifttt_timeout
Open

Add timeout at notify_ifttt#839
r1235613 wants to merge 1 commit intoswar:mainfrom
r1235613:fix_ifttt_timeout

Conversation

@r1235613
Copy link
Copy Markdown
Contributor

Add a timeout setting.
In the current program, if there is a problem with the connection, it can cause the program to hang for a long time.

Signed-off-by: r1235613 <r1235613@gmail.com>
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)")
Copy link
Copy Markdown

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.Timeout:
logging.error(f"Connecting to IFTTT timeout.(Default is 10 sec)")
except requests.exceptions.RequestException as e:
logging.error(f"Fail to connect IFTTT-{str(e)}")
Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants