question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Client spams with warnings "Unable to send to wakeup socket" endlessly

See original GitHub issue

kafka-python version: 2.0.1 python version: 3.7.7

This issue is a duplicate of #1842, that issue is closed and I cannot reopen it. Thus I opened new one.

When I close a spider, kafka starts to spam with “Unable to send to wakeup socket” warning and does not want to stop. Watch attached spider.log file.

I went to sources and add one line which “fix” this issue. Here is original code.

# Source: kafka/client_async.py
# Class: KafkaClient

    def wakeup(self):
        with self._wake_lock:
            try:
                self._wake_w.sendall(b'x')
            except socket.timeout:
                log.warning('Timeout to send to wakeup socket!')
                raise Errors.KafkaTimeoutError()
            except socket.error:
                log.warning('Unable to send to wakeup socket!')

This is fixed.

    def wakeup(self):
        with self._wake_lock:
            try:
                self._wake_w.sendall(b'x')
            except socket.timeout:
                log.warning('Timeout to send to wakeup socket!')
                raise Errors.KafkaTimeoutError()
            except socket.error as e:
                log.warning('Unable to send to wakeup socket!')
                raise e

I do not know what causes the problem and why raising exception stops spam.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:15
  • Comments:11

github_iconTop GitHub Comments

3reactions
mhworthcommented, May 9, 2021

Same here–this happens as soon as I try to gracefully shut down a consumer. As it stands, I have to forcefully kill the process to get it to stop.

1reaction
NitroCaocommented, Nov 8, 2021

I found another way to solve this problem without modifying source code of Kafka-python.

    def run(self) -> Iterator[Event]:
        self._consumer = KafkaConsumer(
            self._kafka_topic,
            bootstrap_servers=self._kafka_server,
            value_deserializer=self.data_deserializer,
            consumer_timeout_ms=16000)

        while not self._stop_receiver:
            try:
                for msg in self._consumer:
                    #  pdb.set_trace()
                    if isinstance(msg.value, Event):
                        yield msg.value
            except StopIteration:
                continue
    
    def close(self):
        if self._consumer is not None:
            #  self._consumer.unsubscribe()
            self._stop_receiver = True
            time.sleep(1)
            self._consumer.unsubscribe()
            self._consumer.close()
Read more comments on GitHub >

github_iconTop Results From Across the Web

Client spams with warnings "Unable to send to ... - Bountysource
This issue is a duplicate of #1842, that issue is closed and I cannot reopen it. Thus I opened new one. When I...
Read more >
Bug listing with status RESOLVED with resolution NEEDINFO ...
status:RESOLVED resolution:NEEDINFO severity:major · Bug:49574 - "CPU temperature warnings whilst booting 2004.1 AMD64 Live CD causing shutdown.
Read more >
fetchmail - fetch mail from a POP, IMAP, ETRN, or ODMR ...
This is a dangerous option and can cause mail loss when used improperly. It deletes old (seen) messages from the mailserver before retrieving...
Read more >
Untitled
typo fix - fixed some rpmlint warnings - Added samples to docs-package ... to close bz#154752 Unable to use --address in client mode...
Read more >
Troubleshooting | Comet Documentation
The connection will fail if the Comet Backup client is not running on the same ... One anti-spam measure in email is Forward...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found