File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed
Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 22import csv
33from datetime import datetime
44
5- import requests
65from cachetools import TTLCache , cached
76
87from ...coordinates import Coordinates
98from ...location .csbs import CSBSLocation
9+ from ...utils import httputils
1010from . import LocationService
1111
1212
@@ -28,15 +28,15 @@ def get(self, loc_id): # pylint: disable=arguments-differ
2828
2929
3030@cached (cache = TTLCache (maxsize = 1 , ttl = 3600 ))
31- def get_locations ():
31+ async def get_locations ():
3232 """
3333 Retrieves county locations; locations are cached for 1 hour
3434
3535 :returns: The locations.
3636 :rtype: dict
3737 """
38- request = requests . get (BASE_URL )
39- text = request .text
38+ async with httputils . client_session . get (BASE_URL ) as response :
39+ text = await response .text ()
4040
4141 data = list (csv .DictReader (text .splitlines ()))
4242
Original file line number Diff line number Diff line change 22import csv
33from datetime import datetime
44
5- import requests
65from cachetools import TTLCache , cached
76
87from ...coordinates import Coordinates
98from ...location import TimelinedLocation
109from ...timeline import Timeline
1110from ...utils import countries
1211from ...utils import date as date_util
12+ from ...utils import httputils
1313from . import LocationService
1414
1515
@@ -37,7 +37,7 @@ def get(self, loc_id): # pylint: disable=arguments-differ
3737
3838
3939@cached (cache = TTLCache (maxsize = 1024 , ttl = 3600 ))
40- def get_category (category ):
40+ async def get_category (category ):
4141 """
4242 Retrieves the data for the provided category. The data is cached for 1 hour.
4343
@@ -52,8 +52,8 @@ def get_category(category):
5252 url = BASE_URL + "time_series_covid19_%s_global.csv" % category
5353
5454 # Request the data
55- request = requests . get (url )
56- text = request .text
55+ async with httputils . client_session . get (url ) as response :
56+ text = await response .text ()
5757
5858 # Parse the CSV.
5959 data = list (csv .DictReader (text .splitlines ()))
You can’t perform that action at this time.
0 commit comments