Skip to content

Commit

Permalink
Call blocking functions using run_in_executor
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaranvpl committed Jun 24, 2024
1 parent c1f85ae commit 48bdb81
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions faststream/confluent/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ def __init__(

self.producer = Producer(self.config, logger=self.logger)
# self.producer.init_transactions()
self.producer.list_topics()
self.loop = loop or asyncio.get_event_loop()
self.loop.run_in_executor(None, self.producer.list_topics)

async def stop(self) -> None:
"""Stop the Kafka producer and flush remaining messages."""
Expand Down Expand Up @@ -359,7 +359,9 @@ def __init__(
self.loop = loop or asyncio.get_event_loop()

if allow_auto_create_topics:
create_topics(topics=self.topics, config=self.config, logger=logger)
self.loop.run_in_executor(
None, create_topics, self.topics, self.config, logger
)
else:
logger.warning( # type: ignore[union-attr]
"Auto create topics is disabled. Make sure the topics exist."
Expand Down

0 comments on commit 48bdb81

Please sign in to comment.