Skip to content

Commit

Permalink
Added timeout for data providers #18
Browse files Browse the repository at this point in the history
  • Loading branch information
pskowronek committed Oct 7, 2023
1 parent f2515db commit a9309b5
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion providers/airly.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def acquire(self):
"apikey" : self.key,
"Accept-Language" : "en",
"Accept" : "application/json"
}
},
timeout=(2, 4)
)
return r.status_code, r.text
except Exception as e:
Expand Down
3 changes: 2 additions & 1 deletion providers/aqicn.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def acquire(self):
"https://api.waqi.info/feed/{}/?token={}".format(
self.city_or_id if self.city_or_id else "geo:{};{}".format(self.lat, self.lon),
self.key
)
),
timeout=(2, 4)
)
return r.status_code, r.text
except Exception as e:
Expand Down
3 changes: 2 additions & 1 deletion providers/darksky.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def acquire(self):
params = {
"units" : self.units,
"exclude" : "minutely,hourly,flags"
}
},
timeout=(2, 4)
)
return r.status_code, r.text

Expand Down
1 change: 1 addition & 0 deletions providers/gmaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def acquire(self):
self.dest_lon,
self.key
),
timeout=(2, 4)
)
return r.status_code, r.text
except Exception as e:
Expand Down
3 changes: 2 additions & 1 deletion providers/openweather.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def acquire(self):
"lat" : self.lat,
"lon" : self.lon,
"units" : self.units
}
},
timeout=(2, 4)
)
return r.status_code, r.text

Expand Down
6 changes: 4 additions & 2 deletions providers/weatherbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def acquire(self):
"lat" : self.lat,
"lon" : self.lon,
"units" : self.units
}
},
timeout=(2, 4)
)
current = r.json()

Expand All @@ -55,7 +56,8 @@ def acquire(self):
"lat" : self.lat,
"lon" : self.lon,
"units" : self.units
}
},
timeout=(2, 4)
)
forecast = r.json()

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ psutil == 5.4.7
uptime == 3.0.1

# providers/meteoalarm.py: 6
meteoalertapi == 0.2.0
meteoalertapi == 0.3.0

0 comments on commit a9309b5

Please sign in to comment.