Skip to content

Commit 101fe34

Browse files
authored
Merge pull request #26 from kusha/macos-fix
MacOS compatibility fix
2 parents 0b943c0 + 78f9090 commit 101fe34

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,20 @@ logger.setLevel(logging.DEBUG)
3030

3131
logger.info('Happy Logging!')
3232
```
33+
34+
Troubleshooting
35+
----------
36+
37+
If you see the following error when running on macOS:
38+
39+
```
40+
Traceback (most recent call last):
41+
File "/path/to/kafka-logging-handler/kafka_logger/handlers.py", line 109, in __init__
42+
'host_ip': socket.gethostbyname(socket.gethostname())
43+
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
44+
```
45+
46+
The issues is that `socket.gethostname()` resolves to a name that is not available in `/etc/hosts`.
47+
First run `python3 -c "import socket; print(socket.gethostname())"` to get the name (e.g. `MacBook-Pro`).
48+
Then fix it with `sudo echo 127.0.0.1 MacBook-Pro >> /etc/hosts`, where `MacBook-Pro` is your computer name.
49+
There won't be OS-specific fix for it in the library.

kafka_logger/handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def at_exit(self):
299299
"main process termination. This may cause logs loss.",
300300
len(children),
301301
)
302-
while self.mp_log_queue.qsize() != 0:
302+
while not self.mp_log_queue.empty():
303303
time.sleep(KafkaLoggingHandler.__MULTIPROCESSING_QUEUE_FLUSH_DELAY)
304304
# wait until everything in multiprocessing queue will be buffered
305305
self.mp_log_handler_flush_lock.acquire()

0 commit comments

Comments
 (0)