Skip to content

Commit 0bd5d2a

Browse files
committed
Explicitly check for None rather than falsey
Be pedantic about checking for identity rather than equality to avoid issues like dpkp#1237 / 411bc08
1 parent 13752d7 commit 0bd5d2a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kafka/client_async.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ def poll(self, timeout_ms=None, future=None, delayed_tasks=True):
539539
task_future.success(result)
540540

541541
# If we got a future that is already done, don't block in _poll
542-
if future and future.is_done:
542+
if future is not None and future.is_done:
543543
timeout = 0
544544
else:
545545
idle_connection_timeout_ms = self._idle_expiry_manager.next_check_ms()
@@ -555,7 +555,7 @@ def poll(self, timeout_ms=None, future=None, delayed_tasks=True):
555555

556556
# If all we had was a timeout (future is None) - only do one poll
557557
# If we do have a future, we keep looping until it is done
558-
if not future or future.is_done:
558+
if future is None or future.is_done:
559559
break
560560

561561
return responses
@@ -660,7 +660,7 @@ def least_loaded_node(self):
660660
conn = self._conns.get(node_id)
661661
connected = conn is not None and conn.connected()
662662
blacked_out = conn is not None and conn.blacked_out()
663-
curr_inflight = len(conn.in_flight_requests) if conn else 0
663+
curr_inflight = len(conn.in_flight_requests) if conn is not None else 0
664664
if connected and curr_inflight == 0:
665665
# if we find an established connection
666666
# with no in-flight requests, we can stop right away

0 commit comments

Comments
 (0)