Challenge: Asynchronous Programming
Test your knowledge of using asynchronous generators to improve your code.
We'll cover the following
Overview
Refactor the program below, which processes a large amount of data synchronously. You should utilize asynchronous programming to improve the processing time.
Requirements
There are two functions, process_data
and process_item
, on lines 4 and 9 respectively that are used to process the data set. The entire dataset is passed to process_data
, which processes each item in the dataset using process_item
. Within process_item
, time.sleep(1)
is used on line 5 to simulate a function that has a large processing time.
Refactor the code below using the asyncio
library to optimize the execution time.
Get hands-on with 1400+ tech skills courses.