def call_weather_api(location): LOGGER.info("call_weather_api") loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) f1 = asyncio.Future() f1.add_done_callback(callback) tasks = [] # tasks.append(get_google_forecast(f1, location)) # tasks.append(get_google_weather(f1, location)) # tasks.append(get_weather(f1, location)) # tasks.append(get_weather_forecast(f1, location)) if util.is_uuid(location): tasks.append(get_weather(f1, location)) else: tasks.append(get_google_weather(f1, location)) loop.run_until_complete(asyncio.wait(tasks)) loop.close() return f1.result()
def call_apis_async(location): start = time.time() loop = asyncio.get_event_loop() f1 = asyncio.Future() f1.add_done_callback(callback_weather) tasks = [] if util.is_uuid(location): tasks.append(HtmlParser2.get_weather(f1, location)) else: tasks.append(HtmlParser2.get_google_weather(f1, location)) loop.run_until_complete(asyncio.wait(tasks)) loop.close() LOGGER.info(f'Total Time Taken {time.time() - start}') print()
def call_weather_api(location): LOGGER.info("call_weather_api") loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) f1 = asyncio.Future() f1.add_done_callback(callback_weather) tasks = [] if util.is_uuid(location): tasks.append(HtmlParser2.get_weather(f1, location)) else: tasks.append(HtmlParser2.get_google_weather(f1, location)) loop.run_until_complete(asyncio.wait(tasks)) loop.close() print()