Last active
November 27, 2021 07:53
-
-
Save wengkham/84e9287955e8a49903d896af3977de4c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
consumer = DeserializingConsumer(consumer_conf) | |
consumer.subscribe("my_topic") | |
async def batch_poll(consumer): | |
with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor: | |
future = executor.submit(consumer.poll) | |
awaitable = await asyncio.wrap_future(future) | |
return awaitable | |
msgs: list = await asyncio.gather(*(batch_poll() for _ in range(10))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment