def sendQuestionsToConnections()

in backend/lambda/connection-stream/lambda.py [0:0]


def sendQuestionsToConnections(connectionChannels, channelQuestions):
    with ThreadPoolExecutor(max_workers=10) as executor:
        allPostsFutures = []
        for connectionId, channel in connectionChannels:
            allPostsFutures.append(
                executor.submit(
                    postQuestions, 
                    connectionId, 
                    channelQuestions[channel]
                )
            )
        for future in as_completed(allPostsFutures):
            try :
                # To surface any exceptions
                future.result()
            except Exception as e:
                print(e)