@@ -1124,7 +1124,7 @@ def _update_fetch_positions(self, timeout_ms=None):
1124
1124
partitions (List[TopicPartition]): The partitions that need
1125
1125
updating fetch positions.
1126
1126
1127
- Returns True if fetch positions updated, False if timeout
1127
+ Returns True if fetch positions updated, False if timeout or async reset is pending
1128
1128
1129
1129
Raises:
1130
1130
NoOffsetForPartitionError: If no offset is stored for a given
@@ -1135,15 +1135,13 @@ def _update_fetch_positions(self, timeout_ms=None):
1135
1135
1136
1136
if (self .config ['api_version' ] >= (0 , 8 , 1 ) and
1137
1137
self .config ['group_id' ] is not None ):
1138
- try :
1139
- # If there are any partitions which do not have a valid position and are not
1140
- # awaiting reset, then we need to fetch committed offsets. We will only do a
1141
- # coordinator lookup if there are partitions which have missing positions, so
1142
- # a consumer with manually assigned partitions can avoid a coordinator dependence
1143
- # by always ensuring that assigned partitions have an initial position.
1144
- self ._coordinator .refresh_committed_offsets_if_needed (timeout_ms = timeout_ms )
1145
- except KafkaTimeoutError :
1146
- pass
1138
+ # If there are any partitions which do not have a valid position and are not
1139
+ # awaiting reset, then we need to fetch committed offsets. We will only do a
1140
+ # coordinator lookup if there are partitions which have missing positions, so
1141
+ # a consumer with manually assigned partitions can avoid a coordinator dependence
1142
+ # by always ensuring that assigned partitions have an initial position.
1143
+ if not self ._coordinator .refresh_committed_offsets_if_needed (timeout_ms = timeout_ms ):
1144
+ return False
1147
1145
1148
1146
# If there are partitions still needing a position and a reset policy is defined,
1149
1147
# request reset using the default policy. If no reset strategy is defined and there
@@ -1152,8 +1150,7 @@ def _update_fetch_positions(self, timeout_ms=None):
1152
1150
1153
1151
# Finally send an asynchronous request to lookup and update the positions of any
1154
1152
# partitions which are awaiting reset.
1155
- self ._fetcher .reset_offsets_if_needed ()
1156
- return False
1153
+ return not self ._fetcher .reset_offsets_if_needed ()
1157
1154
1158
1155
def _message_generator_v2 (self ):
1159
1156
timeout_ms = 1000 * max (0 , self ._consumer_timeout - time .time ())
0 commit comments