Skip to content

Commit 5736393

Browse files
committed
set socket timeout for the wake_w
1 parent 9ac3cb1 commit 5736393

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

kafka/client_async.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ class KafkaClient(object):
151151
'bootstrap_servers': 'localhost',
152152
'client_id': 'kafka-python-' + __version__,
153153
'request_timeout_ms': 30000,
154+
'max_block_ms': 60000,
154155
'connections_max_idle_ms': 9 * 60 * 1000,
155156
'reconnect_backoff_ms': 50,
156157
'reconnect_backoff_max_ms': 1000,
@@ -198,6 +199,7 @@ def __init__(self, **configs):
198199
self._bootstrap_fails = 0
199200
self._wake_r, self._wake_w = socket.socketpair()
200201
self._wake_r.setblocking(False)
202+
self._wake_w.settimeout(self.config['max_block_ms'] / 1000.0)
201203
self._wake_lock = threading.Lock()
202204

203205
self._lock = threading.RLock()

kafka/producer/sender.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Sender(threading.Thread):
2929
'acks': 1,
3030
'retries': 0,
3131
'request_timeout_ms': 30000,
32+
'max_block_ms': 60000,
3233
'guarantee_message_order': False,
3334
'client_id': 'kafka-python-' + __version__,
3435
'api_version': (0, 8, 0),

0 commit comments

Comments
 (0)