aio-libs / aiokafka

asyncio client for kafka

Home Page:http://aiokafka.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistent producer start/stop

valq7711 opened this issue · comments

As there is self._closed = False in __init__, then it requires to call await producer.stop() even if it is not started.

producer = aiokafka.AIOKafkaProducer(bootstrap_servers="localhost:9092")
del producer  # Unclosed AIOKafkaProducer

self._closed = False
# Warn if producer was not closed properly
# We don't attempt to close the Consumer, as __del__ is synchronous
def __del__(self, _warnings=warnings):
if self._closed is False:
_warnings.warn(f"Unclosed AIOKafkaProducer {self!r}",
ResourceWarning,
source=self)