Skip to content

Commit f05c6db

Browse files
authored
coordinator: drop unused future from _failed_request (#3040)
1 parent e89e9db commit f05c6db

3 files changed

Lines changed: 7 additions & 11 deletions

File tree

kafka/coordinator/base.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ async def join_group_async(self, timeout_ms=None):
558558
return True
559559
return True
560560

561-
def _failed_request(self, node_id, request, future, error):
561+
def _failed_request(self, node_id, request, error):
562562
# Marking coordinator dead
563563
# unless the error is caused by internal client pipelining or throttling
564564
if not isinstance(error, (Errors.NodeNotReadyError,
@@ -570,8 +570,6 @@ def _failed_request(self, node_id, request, future, error):
570570
else:
571571
log.debug('Error sending %s to node %s [%s]',
572572
request.__class__.__name__, node_id, error)
573-
if future is not None:
574-
future.failure(error)
575573

576574
def _process_join_group_response(self, response, send_time):
577575
"""Classify a JoinGroupResponse: mutate state on success, raise on error.
@@ -841,7 +839,7 @@ async def _send_group_coordinator_request(self):
841839
try:
842840
response = await self._manager.send(request, node_id=node_id)
843841
except Exception as exc:
844-
self._failed_request(node_id, request, None, exc)
842+
self._failed_request(node_id, request, exc)
845843
raise
846844
return self._handle_find_coordinator_response(response)
847845

@@ -1128,7 +1126,7 @@ async def _send_heartbeat_request(self):
11281126
response = await self._manager.send(request, node_id=self.coordinator_id)
11291127
return self._handle_heartbeat_response(response, send_time)
11301128
except Errors.KafkaError as exc:
1131-
self._failed_request(self.coordinator_id, request, None, exc)
1129+
self._failed_request(self.coordinator_id, request, exc)
11321130
raise
11331131

11341132
def _handle_heartbeat_response(self, response, send_time):

kafka/coordinator/consumer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ async def _send_offset_commit_request(self, offsets):
959959
try:
960960
response = await self._manager.send(request, node_id=node_id)
961961
except Exception as exc:
962-
self._failed_request(node_id, request, None, exc)
962+
self._failed_request(node_id, request, exc)
963963
raise
964964
self._handle_offset_commit_response(offsets, send_time, response)
965965

@@ -1097,7 +1097,7 @@ async def _send_offset_fetch_request(self, partitions):
10971097
try:
10981098
response = await self._manager.send(request, node_id=node_id)
10991099
except Exception as exc:
1100-
self._failed_request(node_id, request, None, exc)
1100+
self._failed_request(node_id, request, exc)
11011101
raise
11021102
return self._handle_offset_fetch_response(response)
11031103

test/consumer/test_coordinator.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -651,10 +651,9 @@ def test_send_offset_commit_request_failure(mocker, broker, seeded_coord, offset
651651
# effect (mark coordinator dead); future arg is None since the
652652
# coroutine itself surfaces the exception.
653653
assert spy.call_count == 1
654-
node_id, request, call_future, call_error = spy.call_args[0]
654+
node_id, request, call_error = spy.call_args[0]
655655
assert node_id == 0
656656
assert isinstance(request, OffsetCommitRequest)
657-
assert call_future is None
658657
assert call_error is error
659658

660659

@@ -809,10 +808,9 @@ def test_send_offset_fetch_request_failure(mocker, broker, seeded_coord, partiti
809808
# the exception. _failed_request still fires for its side effect
810809
# (mark coordinator dead) with future=None.
811810
assert spy.call_count == 1
812-
node_id, request, call_future, call_error = spy.call_args[0]
811+
node_id, request, call_error = spy.call_args[0]
813812
assert node_id == 0
814813
assert isinstance(request, OffsetFetchRequest)
815-
assert call_future is None
816814
assert call_error is error
817815

818816

0 commit comments

Comments
 (0)