Browse Source

Fix flake8

pull/181/head
Vincent Mézino 7 years ago
parent
commit
839dba3411
  1. 8
      socketio/kafka_manager.py

8
socketio/kafka_manager.py

@ -25,8 +25,9 @@ class KafkaManager(PubSubManager): # pragma: no cover
:param url: The connection URL for the Kafka server. For a default Kafka :param url: The connection URL for the Kafka server. For a default Kafka
store running on the same host, use ``kafka://``. store running on the same host, use ``kafka://``.
:param channel: The channel name (topic) on which the server sends and receives :param channel: The channel name (topic) on which the server sends and
notifications. Must be the same in all the servers. receives notifications. Must be the same in all the
servers.
:param write_only: If set ot ``True``, only initialize to emit events. The :param write_only: If set ot ``True``, only initialize to emit events. The
default of ``False`` initializes the class for emitting default of ``False`` initializes the class for emitting
and receiving. and receiving.
@ -48,17 +49,14 @@ class KafkaManager(PubSubManager): # pragma: no cover
self.consumer = kafka.KafkaConsumer(self.channel, self.consumer = kafka.KafkaConsumer(self.channel,
bootstrap_servers=self.kafka_url) bootstrap_servers=self.kafka_url)
def _publish(self, data): def _publish(self, data):
self.producer.send(self.channel, value=pickle.dumps(data)) self.producer.send(self.channel, value=pickle.dumps(data))
self.producer.flush() self.producer.flush()
def _kafka_listen(self): def _kafka_listen(self):
for message in self.consumer: for message in self.consumer:
yield message yield message
def _listen(self): def _listen(self):
for message in self._kafka_listen(): for message in self._kafka_listen():
if message.topic == self.channel: if message.topic == self.channel:

Loading…
Cancel
Save