Skip to content

Instantly share code, notes, and snippets.

@wengkham
Last active November 27, 2021 07:53
Show Gist options
  • Save wengkham/84e9287955e8a49903d896af3977de4c to your computer and use it in GitHub Desktop.
Save wengkham/84e9287955e8a49903d896af3977de4c to your computer and use it in GitHub Desktop.
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