Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5fe9c61

Browse files
committed
Forgot to asyncify the load testing waiting.
1 parent a5c04bb commit 5fe9c61

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/10-async-web/acityscape_api/services/location_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import asyncio
12
import random
2-
import time
33
from typing import Tuple
44

55
import aiohttp
@@ -16,7 +16,7 @@ async def get_lat_long(zip_code: str, country: str) -> Tuple[float, float]:
1616
url = f'http://www.datasciencetoolkit.org/street2coordinates/{key.replace(" ", "+")}'
1717

1818
if use_cached_data:
19-
time.sleep(random.choice(measured_latency_in_sec))
19+
await asyncio.sleep(random.choice(measured_latency_in_sec))
2020
return 45.50655, -122.733888
2121
else:
2222
async with aiohttp.ClientSession() as session:

src/10-async-web/acityscape_api/services/sun_service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncio
12
import datetime
23
import random
34
import time
@@ -12,7 +13,7 @@ async def for_today(latitude: float, longitude: float) -> dict:
1213
url = f'https://api.sunrise-sunset.org/json?lat={latitude}&lng={longitude}'
1314

1415
if use_cached_data: # Set in config/dev.json or config/prod.json
15-
time.sleep(random.choice(measured_latency_in_sec))
16+
await asyncio.sleep(random.choice(measured_latency_in_sec))
1617
return {'sunrise': '06:04:09 AM', 'sunset': '08:28:48 PM', 'solar_noon': '01:16:28 PM',
1718
'day_length': '14:24:39', 'civil_twilight_begin': '05:31:10 AM', 'civil_twilight_end': '09:01:47 PM',
1819
'nautical_twilight_begin': '04:49:54 AM', 'nautical_twilight_end': '09:43:03 PM',

0 commit comments

Comments
 (0)