Hello, I'm facing with problem. I implemented AbstractTokenProvider for my producer client. But I also need to create and delete topics. From my understanding, I can perform these actions only with kafka-python package, which only supports non-async function calls. It is recommended to use this code in the documentation:
from aiokafka.abc import AbstractTokenProvider
class CustomTokenProvider(AbstractTokenProvider):
async def token(self):
return asyncio.get_running_loop().run_in_executor(
None, self._token)
def _token(self):
# The actual synchoronous token callback.
But I get an error if I try use my class for configure sasl_oauth_token_provider for KafkaAdminClient in package kafka-python:
kafka\conn.py:824: RuntimeWarning: coroutine 'AsyncCustomTokenProvider.token' was never awaited
And about my question. Can I implement my case using only one AbstractTokenProvider? Or I must implement Async class for aiokafka and implement Sync class for kafka-python. Thanks for any advice.
Hello, I'm facing with problem. I implemented
AbstractTokenProvider
for my producer client. But I also need to create and delete topics. From my understanding, I can perform these actions only withkafka-python
package, which only supports non-async function calls. It is recommended to use this code in the documentation:In my implementation, it looks like:
But I get an error if I try use my class for configure
sasl_oauth_token_provider
forKafkaAdminClient
in packagekafka-python
:kafka\conn.py:824: RuntimeWarning: coroutine 'AsyncCustomTokenProvider.token' was never awaited
And about my question. Can I implement my case using only oneAbstractTokenProvider
? Or I must implement Async class foraiokafka
and implement Sync class forkafka-python
. Thanks for any advice.