You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Client spams with warnings "Unable to send to wakeup socket" endlessly #2073
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: KafkaClientdefwakeup(self):
withself._wake_lock:
try:
self._wake_w.sendall(b'x')
exceptsocket.timeout:
log.warning('Timeout to send to wakeup socket!')
raiseErrors.KafkaTimeoutError()
exceptsocket.error:
log.warning('Unable to send to wakeup socket!')
This is fixed.
defwakeup(self):
withself._wake_lock:
try:
self._wake_w.sendall(b'x')
exceptsocket.timeout:
log.warning('Timeout to send to wakeup socket!')
raiseErrors.KafkaTimeoutError()
exceptsocket.errorase:
log.warning('Unable to send to wakeup socket!')
raisee
I do not know what causes the problem and why raising exception stops spam.
Reacted by Luis J., Michael Rademaker, Bulat Kurbangaliev, João Carlos, lennstof, dorellang, Andrey Saprykin, Patrick McConnell, kstachniuk, FAN-GOD and 3 more
Having the same issue also with kafka-python 2.0.1. Don't know what causes it. After reboot it stops for a while but seems to get triggered when receiving data.
I consistently ran into this when accidentally using a closed consumer, underlying socket exception was "Bad file descriptor", should someone run into the same issue. Error was on my part, but some sanity check with a nicer error message for this could have saved me an hour or so of debugging.
We have a custom context manager for setting up and closing a consumer, I was using the consumer after it had been closed. Fix is simply not to do that. Code was more complex than the example, but simplified, it boils down to this:
withcreate_consumer() asconsumer:
# Use consumer here.
...
# If you use it here, outside the managed context, it's closed# and you get a bad file descriptor error.
Activity
joaomcarlos commentedon Jul 15, 2020
I am seeing the same behavior with
nameko_kafkawhich uses this lib internally.Miggets7 commentedon Jul 28, 2020
Having the same issue with the same lib version and python version in a docker container using
python:3.7-slim-stretchpeilingkuang commentedon Aug 17, 2020
i have the same behavior in 2.0.1
tuofang commentedon Aug 17, 2020
Having the same issue with the same kafka-python version of 2.0.1
lennstof commentedon Sep 7, 2020
Having the same issue also with kafka-python 2.0.1. Don't know what causes it. After reboot it stops for a while but seems to get triggered when receiving data.
ninakka commentedon Feb 4, 2021
Is there any progress on this issue ? I am also hitting this issue. I am using 1.4.7 where #1842 says it is fixed.
From @dpkp "I believe this is fixed in the latest release, 1.4.7. Please reopen if the issue persists."
@Prometheus3375 proposed a fix above. Can it be reviewed for picking up?
FANGOD commentedon Mar 16, 2021
This problem occasionally occurs when closing a Kafka link, Is there a mistake?
forgoty commentedon May 7, 2021
Confirm. Issue persists when trying to close the consumer connection with Kafka inside docker container.
mhworth commentedon 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.
vlaskinvlad commentedon Jun 14, 2021
Same
+1
NitroCao commentedon Nov 8, 2021
I found another way to solve this problem without modifying source code of Kafka-python.
glorinli commentedon Jul 19, 2023
It works, seems the consumer_timeout_ms is the key point.
aiven-anton commentedon Sep 28, 2023
I consistently ran into this when accidentally using a closed consumer, underlying socket exception was
"Bad file descriptor", should someone run into the same issue. Error was on my part, but some sanity check with a nicer error message for this could have saved me an hour or so of debugging.adityaraj-28 commentedon Oct 10, 2023
@aiven-anton What was the fix for you, I am getting the same "Bad file descriptor"
aiven-anton commentedon Oct 10, 2023
@adityaraj-28
We have a custom context manager for setting up and closing a consumer, I was using the consumer after it had been closed. Fix is simply not to do that. Code was more complex than the example, but simplified, it boils down to this:
dpkp commentedon Feb 16, 2025
Should be fixed in #2482