Skip to content

Commit 47156c3

Browse files
authored
Avoid self-join in heartbeat thread close (#2488)
1 parent 4281e3e commit 47156c3

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

kafka/coordinator/base.py

+9
Original file line numberDiff line numberDiff line change
@@ -920,9 +920,18 @@ def disable(self):
920920
self.enabled = False
921921

922922
def close(self):
923+
if self.closed:
924+
return
923925
self.closed = True
924926
with self.coordinator._lock:
925927
self.coordinator._lock.notify()
928+
929+
# Generally this should not happen - close() is triggered
930+
# by the coordinator. But in some cases GC may close the coordinator
931+
# from within the heartbeat thread.
932+
if threading.current_thread() == self:
933+
return
934+
926935
if self.is_alive():
927936
self.join(self.coordinator.config['heartbeat_interval_ms'] / 1000)
928937
if self.is_alive():

0 commit comments

Comments
 (0)