@@ -709,29 +709,27 @@ def covidcast_nowcast(
709709 return Epidata ._request (params )
710710
711711 @staticmethod
712- async def async_get (params , session ):
713- """Helper function to make Epidata GET requests."""
714- async with session .get (Epidata .BASE_URL , params = params ) as response :
715- return await response .json (), params
716-
717- @staticmethod
718- async def async_fetch_epidata (param_combos ):
719- """Helper function to asynchronously make and aggregate Epidata GET requests."""
720- tasks = []
721- async with ClientSession () as session :
722- for param in param_combos :
723- task = asyncio .ensure_future (Epidata .async_get (param , session ))
724- tasks .append (task )
725- responses = await asyncio .gather (* tasks )
726- return responses
727-
728- @staticmethod
729- def async_call (param_list , batch_size = 100 ):
712+ def async_epidata (param_list , batch_size = 100 ):
730713 """Make asynchronous Epidata calls for a list of parameters."""
714+ async def async_get (params , session ):
715+ """Helper function to make Epidata GET requests."""
716+ async with session .get (Epidata .BASE_URL , params = params ) as response :
717+ return await response .json (), params
718+
719+ async def async_make_calls (param_combos ):
720+ """Helper function to asynchronously make and aggregate Epidata GET requests."""
721+ tasks = []
722+ async with ClientSession () as session :
723+ for param in param_combos :
724+ task = asyncio .ensure_future (async_get (param , session ))
725+ tasks .append (task )
726+ responses = await asyncio .gather (* tasks )
727+ return responses
728+
731729 batches = [param_list [i :i + batch_size ] for i in range (0 , len (param_list ), batch_size )]
732730 responses = []
733731 for batch in batches :
734732 loop = asyncio .get_event_loop ()
735- future = asyncio .ensure_future (Epidata . async_fetch_epidata (batch ))
733+ future = asyncio .ensure_future (async_make_calls (batch ))
736734 responses += loop .run_until_complete (future )
737735 return responses
0 commit comments