app/lists.py
async def import_list_members(self):
        """Requests basic information about MailChimp list members in chunks.

        This includes the member status, member stats, etc.
        Requests are made asynchronously (up to CHUNK_SIZE members
        per requests) using aiohttp. This speeds up the process
        significantly and prevents timeouts.
        After the requests have completed, parses the results and turns
        them into a pandas dataframe.
        """

        # Enable a proxy
        await self.enable_proxy()

        # MailChimp API endpoint for requests
        request_uri = ('https://{}.api.mailchimp.com/3.0/lists/{}/'
                       'members'.format(self.data_center, self.id))

        # List of async tasks to do
        tasks = []

        # Placeholder for async responses
        responses = None

        # Semaphore to limit max simultaneous connections to MailChimp API
        sem = asyncio.Semaphore(self.MAX_CONNECTIONS)

        # The total number of chunks, i.e. requests to make to MailChimp
        # If list is smaller than CHUNK_SIZE, this is 1 request
        number_of_chunks = (1 if self.count < self.CHUNK_SIZE
                            else self.count // self.CHUNK_SIZE + 1)

        # Make requests with a single session
        async with ClientSession() as session:
            for chunk_num in range(number_of_chunks):

                # Calculate the number of members in this request
                chunk = (str(self.count % self.CHUNK_SIZE
                             if chunk_num == number_of_chunks - 1
                             else self.CHUNK_SIZE))

                # Calculate where to begin request from
                offset = str(chunk_num * self.CHUNK_SIZE)

                params = (
                    ('fields', 'members.status,'
                               'members.timestamp_opt,'
                               'members.timestamp_signup,'
                               'members.stats,members.id'),
                    ('count', chunk),
                    ('offset', offset),
                )

                # Add a new import task to the queue for each chunk
                task = asyncio.ensure_future(
                    self.make_async_requests(
                        sem, request_uri, params, session))
                tasks.append(task)

            # Await completion of all requests and gather results
            responses = await asyncio.gather(*tasks)

        # Flatten the responses into a single list of dicts
        list_data = [response
                     for response_dict in responses
                     for v in response_dict.values()
                     for response in v]

        # Create a pandas dataframe to store the results
        self.df = pd.DataFrame(list_data)
Requests basic information about MailChimp list members in chunks.

        This includes the member status, member stats, etc.
        Requests are made asynchronously (up to CHUNK_SIZE members
        per requests) using aiohttp. This speeds up the process
        significantly and prevents timeouts.
        After the requests have completed, parses the results and turns
        them into a pandas dataframe.
        
Requests basic information about MailChimp list members in chunks.
This includes the member status, member stats, etc.
Requests are made asynchronously (up to CHUNK_SIZE members
per requests) using aiohttp. This speeds up the process
significantly and prevents timeouts.
After the requests have completed, parses the results and turns
them into a pandas dataframe.
Requests basic information about MailChimp list members in chunks . This includes the member status member stats etc . Requests are made asynchronously ( up to CHUNK_SIZE members per requests ) using aiohttp . This speeds up the process significantly and prevents timeouts . After the requests have completed parses the results and turns them into a pandas dataframe .
async def import_list_members(self):
        await self.enable_proxy()
        request_uri = ('https://{}.api.mailchimp.com/3.0/lists/{}/'
                       'members'.format(self.data_center, self.id))
        tasks = []
        responses = None
        sem = asyncio.Semaphore(self.MAX_CONNECTIONS)
        number_of_chunks = (1 if self.count < self.CHUNK_SIZE
                            else self.count // self.CHUNK_SIZE + 1)
        async with ClientSession() as session:
            for chunk_num in range(number_of_chunks):
                chunk = (str(self.count % self.CHUNK_SIZE
                             if chunk_num == number_of_chunks - 1
                             else self.CHUNK_SIZE))
                offset = str(chunk_num * self.CHUNK_SIZE)
                params = (
                    ('fields', 'members.status,'
                               'members.timestamp_opt,'
                               'members.timestamp_signup,'
                               'members.stats,members.id'),
                    ('count', chunk),
                    ('offset', offset),
                )
                task = asyncio.ensure_future(
                    self.make_async_requests(
                        sem, request_uri, params, session))
                tasks.append(task)
            responses = await asyncio.gather(*tasks)
        list_data = [response
                     for response_dict in responses
                     for v in response_dict.values()
                     for response in v]
        self.df = pd.DataFrame(list_data)
async def import_list_members ( self ) : await self . enable_proxy ( ) request_uri = ( 'https://{}.api.mailchimp.com/3.0/lists/{}/' 'members' . format ( self . data_center , self . id ) ) tasks = [ ] responses = None sem = asyncio . Semaphore ( self . MAX_CONNECTIONS ) number_of_chunks = ( 1 if self . count < self . CHUNK_SIZE else self . count // self . CHUNK_SIZE + 1 ) async with ClientSession ( ) as session : for chunk_num in range ( number_of_chunks ) : chunk = ( str ( self . count % self . CHUNK_SIZE if chunk_num == number_of_chunks - 1 else self . CHUNK_SIZE ) ) offset = str ( chunk_num * self . CHUNK_SIZE ) params = ( ( 'fields' , 'members.status,' 'members.timestamp_opt,' 'members.timestamp_signup,' 'members.stats,members.id' ) , ( 'count' , chunk ) , ( 'offset' , offset ) , ) task = asyncio . ensure_future ( self . make_async_requests ( sem , request_uri , params , session ) ) tasks . append ( task ) responses = await asyncio . gather ( * tasks ) list_data = [ response for response_dict in responses for v in response_dict . values ( ) for response in v ] self . df = pd . DataFrame ( list_data )
Requests basic information about MailChimp list members in chunks.
Requests basic information about MailChimp list members in chunks .
"""Requests basic information about MailChimp list members in chunks.

        This includes the member status, member stats, etc.
        Requests are made asynchronously (up to CHUNK_SIZE members
        per requests) using aiohttp. This speeds up the process
        significantly and prevents timeouts.
        After the requests have completed, parses the results and turns
        them into a pandas dataframe.
        """ # Enable a proxy
 # MailChimp API endpoint for requests
 # List of async tasks to do
 # Placeholder for async responses
 # Semaphore to limit max simultaneous connections to MailChimp API
 # The total number of chunks, i.e. requests to make to MailChimp
 # If list is smaller than CHUNK_SIZE, this is 1 request
 # Make requests with a single session
 # Calculate the number of members in this request
 # Calculate where to begin request from
 # Add a new import task to the queue for each chunk
 # Await completion of all requests and gather results
 # Flatten the responses into a single list of dicts
 # Create a pandas dataframe to store the results

self