Skip to content

Commit 115d28b

Browse files
author
Dana Powers
committed
Update SimpleClient w/ connnect_blocking()
1 parent bacba53 commit 115d28b

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

kafka/client.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,7 @@ def _get_conn(self, host, port, afi):
7171
)
7272

7373
conn = self._conns[host_key]
74-
conn.connect()
75-
if conn.connected():
76-
return conn
77-
78-
timeout = time.time() + self.timeout
79-
while time.time() < timeout and conn.connecting():
80-
if conn.connect() is ConnectionStates.CONNECTED:
81-
break
82-
else:
83-
time.sleep(0.05)
84-
else:
74+
if not conn.connect_blocking(self.timeout):
8575
conn.close()
8676
raise ConnectionError("%s:%s (%s)" % (host, port, afi))
8777
return conn

0 commit comments

Comments
 (0)