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

weather.sh: added timeouts to curl requests #289

Merged
merged 2 commits into from
Oct 18, 2024

Conversation

ikubetoomuzik
Copy link
Contributor

wttr.in occasionally has issues where requests hang, this can cause issues in the status bar.

changed the script so it exports defined functions and calls them in a sub-shell. This allows for use of the timeout command on bash functions.

this allows for quitting early if wttr.in is having an issue. recently
wttr.in had an issue where it would hang on requests, causing the status
bar to fail.
If the last data that we received was actually an error message then we
instead retry the connection every 1 minute until we get a valid
status. This allows for faster recovery if the last check timed up with
a network error.
@ethancedwards8 ethancedwards8 merged commit ec85f84 into dracula:master Oct 18, 2024
1 check passed
@ethancedwards8
Copy link
Member

Brilliant. Thanks.

@mamantoha
Copy link
Contributor

Hi @ethancedwards8. Please revert this PR as it completely breaks the weather display.

main()
{
# process should be cancelled when session is killed
if timeout 1 bash -c "</dev/tcp/ipinfo.io/443" && timeout 1 bash -c "</dev/tcp/wttr.in/443"; then
echo "$(display_weather)$(display_location)"
if ! weather=$(timeout 3 bash -c "display_weather $fahrenheit"); then
Copy link
Contributor

Choose a reason for hiding this comment

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

$(display_location) is missing here.
Why $fahrenheit only?

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

Successfully merging this pull request may close these issues.

3 participants