kafka-python 2.2.8__py2.py3-none-any.whl → 2.2.10__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kafka/conn.py +1 -1
- kafka/consumer/fetcher.py +6 -1
- kafka/consumer/group.py +14 -14
- kafka/coordinator/consumer.py +7 -1
- kafka/sasl/gssapi.py +12 -5
- kafka/version.py +1 -1
- {kafka_python-2.2.8.dist-info → kafka_python-2.2.10.dist-info}/METADATA +1 -1
- {kafka_python-2.2.8.dist-info → kafka_python-2.2.10.dist-info}/RECORD +10 -10
- {kafka_python-2.2.8.dist-info → kafka_python-2.2.10.dist-info}/WHEEL +0 -0
- {kafka_python-2.2.8.dist-info → kafka_python-2.2.10.dist-info}/top_level.txt +0 -0
kafka/conn.py
CHANGED
|
@@ -313,7 +313,7 @@ class BrokerConnection(object):
|
|
|
313
313
|
|
|
314
314
|
def _init_sasl_mechanism(self):
|
|
315
315
|
if self.config['security_protocol'] in ('SASL_PLAINTEXT', 'SASL_SSL'):
|
|
316
|
-
self._sasl_mechanism = get_sasl_mechanism(self.config['sasl_mechanism'])(**self.config)
|
|
316
|
+
self._sasl_mechanism = get_sasl_mechanism(self.config['sasl_mechanism'])(host=self.host, **self.config)
|
|
317
317
|
else:
|
|
318
318
|
self._sasl_mechanism = None
|
|
319
319
|
|
kafka/consumer/fetcher.py
CHANGED
|
@@ -178,6 +178,9 @@ class Fetcher(six.Iterator):
|
|
|
178
178
|
Arguments:
|
|
179
179
|
partitions ([TopicPartition]): the partitions that need offsets reset
|
|
180
180
|
|
|
181
|
+
Returns:
|
|
182
|
+
bool: True if any partitions need reset; otherwise False (no reset pending)
|
|
183
|
+
|
|
181
184
|
Raises:
|
|
182
185
|
NoOffsetForPartitionError: if no offset reset strategy is defined
|
|
183
186
|
KafkaTimeoutError if timeout_ms provided
|
|
@@ -189,7 +192,8 @@ class Fetcher(six.Iterator):
|
|
|
189
192
|
|
|
190
193
|
partitions = self._subscriptions.partitions_needing_reset()
|
|
191
194
|
if not partitions:
|
|
192
|
-
return
|
|
195
|
+
return False
|
|
196
|
+
log.debug('Resetting offsets for %s', partitions)
|
|
193
197
|
|
|
194
198
|
offset_resets = dict()
|
|
195
199
|
for tp in partitions:
|
|
@@ -198,6 +202,7 @@ class Fetcher(six.Iterator):
|
|
|
198
202
|
offset_resets[tp] = ts
|
|
199
203
|
|
|
200
204
|
self._reset_offsets_async(offset_resets)
|
|
205
|
+
return True
|
|
201
206
|
|
|
202
207
|
def offsets_by_times(self, timestamps, timeout_ms=None):
|
|
203
208
|
"""Fetch offset for each partition passed in ``timestamps`` map.
|
kafka/consumer/group.py
CHANGED
|
@@ -699,6 +699,7 @@ class KafkaConsumer(six.Iterator):
|
|
|
699
699
|
dict: Map of topic to list of records (may be empty).
|
|
700
700
|
"""
|
|
701
701
|
if not self._coordinator.poll(timeout_ms=timer.timeout_ms):
|
|
702
|
+
log.debug('poll: timeout during coordinator.poll(); returning early')
|
|
702
703
|
return {}
|
|
703
704
|
|
|
704
705
|
has_all_fetch_positions = self._update_fetch_positions(timeout_ms=timer.timeout_ms)
|
|
@@ -706,13 +707,13 @@ class KafkaConsumer(six.Iterator):
|
|
|
706
707
|
# If data is available already, e.g. from a previous network client
|
|
707
708
|
# poll() call to commit, then just return it immediately
|
|
708
709
|
records, partial = self._fetcher.fetched_records(max_records, update_offsets=update_offsets)
|
|
709
|
-
log.debug('
|
|
710
|
+
log.debug('poll: fetched records: %s, %s', records, partial)
|
|
710
711
|
# Before returning the fetched records, we can send off the
|
|
711
712
|
# next round of fetches and avoid block waiting for their
|
|
712
713
|
# responses to enable pipelining while the user is handling the
|
|
713
714
|
# fetched records.
|
|
714
715
|
if not partial:
|
|
715
|
-
log.debug("Sending fetches")
|
|
716
|
+
log.debug("poll: Sending fetches")
|
|
716
717
|
futures = self._fetcher.send_fetches()
|
|
717
718
|
if len(futures):
|
|
718
719
|
self._client.poll(timeout_ms=0)
|
|
@@ -724,12 +725,14 @@ class KafkaConsumer(six.Iterator):
|
|
|
724
725
|
# since the offset lookup may be backing off after a failure
|
|
725
726
|
poll_timeout_ms = min(timer.timeout_ms, self._coordinator.time_to_next_poll() * 1000)
|
|
726
727
|
if not has_all_fetch_positions:
|
|
728
|
+
log.debug('poll: do not have all fetch positions...')
|
|
727
729
|
poll_timeout_ms = min(poll_timeout_ms, self.config['retry_backoff_ms'])
|
|
728
730
|
|
|
729
731
|
self._client.poll(timeout_ms=poll_timeout_ms)
|
|
730
732
|
# after the long poll, we should check whether the group needs to rebalance
|
|
731
733
|
# prior to returning data so that the group can stabilize faster
|
|
732
734
|
if self._coordinator.need_rejoin():
|
|
735
|
+
log.debug('poll: coordinator needs rejoin; returning early')
|
|
733
736
|
return {}
|
|
734
737
|
|
|
735
738
|
records, _ = self._fetcher.fetched_records(max_records, update_offsets=update_offsets)
|
|
@@ -1124,7 +1127,7 @@ class KafkaConsumer(six.Iterator):
|
|
|
1124
1127
|
partitions (List[TopicPartition]): The partitions that need
|
|
1125
1128
|
updating fetch positions.
|
|
1126
1129
|
|
|
1127
|
-
Returns True if fetch positions updated, False if timeout
|
|
1130
|
+
Returns True if fetch positions updated, False if timeout or async reset is pending
|
|
1128
1131
|
|
|
1129
1132
|
Raises:
|
|
1130
1133
|
NoOffsetForPartitionError: If no offset is stored for a given
|
|
@@ -1135,15 +1138,13 @@ class KafkaConsumer(six.Iterator):
|
|
|
1135
1138
|
|
|
1136
1139
|
if (self.config['api_version'] >= (0, 8, 1) and
|
|
1137
1140
|
self.config['group_id'] is not None):
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
except KafkaTimeoutError:
|
|
1146
|
-
pass
|
|
1141
|
+
# If there are any partitions which do not have a valid position and are not
|
|
1142
|
+
# awaiting reset, then we need to fetch committed offsets. We will only do a
|
|
1143
|
+
# coordinator lookup if there are partitions which have missing positions, so
|
|
1144
|
+
# a consumer with manually assigned partitions can avoid a coordinator dependence
|
|
1145
|
+
# by always ensuring that assigned partitions have an initial position.
|
|
1146
|
+
if not self._coordinator.refresh_committed_offsets_if_needed(timeout_ms=timeout_ms):
|
|
1147
|
+
return False
|
|
1147
1148
|
|
|
1148
1149
|
# If there are partitions still needing a position and a reset policy is defined,
|
|
1149
1150
|
# request reset using the default policy. If no reset strategy is defined and there
|
|
@@ -1152,8 +1153,7 @@ class KafkaConsumer(six.Iterator):
|
|
|
1152
1153
|
|
|
1153
1154
|
# Finally send an asynchronous request to lookup and update the positions of any
|
|
1154
1155
|
# partitions which are awaiting reset.
|
|
1155
|
-
self._fetcher.reset_offsets_if_needed()
|
|
1156
|
-
return False
|
|
1156
|
+
return not self._fetcher.reset_offsets_if_needed()
|
|
1157
1157
|
|
|
1158
1158
|
def _message_generator_v2(self):
|
|
1159
1159
|
timeout_ms = 1000 * max(0, self._consumer_timeout - time.time())
|
kafka/coordinator/consumer.py
CHANGED
|
@@ -274,6 +274,7 @@ class ConsumerCoordinator(BaseCoordinator):
|
|
|
274
274
|
try:
|
|
275
275
|
self._invoke_completed_offset_commit_callbacks()
|
|
276
276
|
if not self.ensure_coordinator_ready(timeout_ms=timer.timeout_ms):
|
|
277
|
+
log.debug('coordinator.poll: timeout in ensure_coordinator_ready; returning early')
|
|
277
278
|
return False
|
|
278
279
|
|
|
279
280
|
if self.config['api_version'] >= (0, 9) and self._subscription.partitions_auto_assigned():
|
|
@@ -293,9 +294,11 @@ class ConsumerCoordinator(BaseCoordinator):
|
|
|
293
294
|
metadata_update = self._client.cluster.request_update()
|
|
294
295
|
self._client.poll(future=metadata_update, timeout_ms=timer.timeout_ms)
|
|
295
296
|
if not metadata_update.is_done:
|
|
297
|
+
log.debug('coordinator.poll: timeout updating metadata; returning early')
|
|
296
298
|
return False
|
|
297
299
|
|
|
298
300
|
if not self.ensure_active_group(timeout_ms=timer.timeout_ms):
|
|
301
|
+
log.debug('coordinator.poll: timeout in ensure_active_group; returning early')
|
|
299
302
|
return False
|
|
300
303
|
|
|
301
304
|
self.poll_heartbeat()
|
|
@@ -427,7 +430,8 @@ class ConsumerCoordinator(BaseCoordinator):
|
|
|
427
430
|
future_key = frozenset(partitions)
|
|
428
431
|
timer = Timer(timeout_ms)
|
|
429
432
|
while True:
|
|
430
|
-
self.ensure_coordinator_ready(timeout_ms=timer.timeout_ms)
|
|
433
|
+
if not self.ensure_coordinator_ready(timeout_ms=timer.timeout_ms):
|
|
434
|
+
timer.maybe_raise()
|
|
431
435
|
|
|
432
436
|
# contact coordinator to fetch committed offsets
|
|
433
437
|
if future_key in self._offset_fetch_futures:
|
|
@@ -722,6 +726,7 @@ class ConsumerCoordinator(BaseCoordinator):
|
|
|
722
726
|
return future
|
|
723
727
|
|
|
724
728
|
def _handle_offset_commit_response(self, offsets, future, send_time, response):
|
|
729
|
+
log.debug("Received OffsetCommitResponse: %s", response)
|
|
725
730
|
# TODO look at adding request_latency_ms to response (like java kafka)
|
|
726
731
|
if self._consumer_sensors:
|
|
727
732
|
self._consumer_sensors.commit_latency.record((time.time() - send_time) * 1000)
|
|
@@ -848,6 +853,7 @@ class ConsumerCoordinator(BaseCoordinator):
|
|
|
848
853
|
return future
|
|
849
854
|
|
|
850
855
|
def _handle_offset_fetch_response(self, future, response):
|
|
856
|
+
log.debug("Received OffsetFetchResponse: %s", response)
|
|
851
857
|
if response.API_VERSION >= 2 and response.error_code != Errors.NoError.errno:
|
|
852
858
|
error_type = Errors.for_code(response.error_code)
|
|
853
859
|
log.debug("Offset fetch failed: %s", error_type.__name__)
|
kafka/sasl/gssapi.py
CHANGED
|
@@ -26,14 +26,15 @@ class SaslMechanismGSSAPI(SaslMechanism):
|
|
|
26
26
|
raise ValueError('sasl_kerberos_service_name or sasl_kerberos_name required for GSSAPI sasl configuration')
|
|
27
27
|
self._is_done = False
|
|
28
28
|
self._is_authenticated = False
|
|
29
|
+
self.gssapi_name = None
|
|
29
30
|
if config.get('sasl_kerberos_name', None) is not None:
|
|
30
31
|
self.auth_id = str(config['sasl_kerberos_name'])
|
|
32
|
+
if isinstance(config['sasl_kerberos_name'], gssapi.Name):
|
|
33
|
+
self.gssapi_name = config['sasl_kerberos_name']
|
|
31
34
|
else:
|
|
32
35
|
kerberos_domain_name = config.get('sasl_kerberos_domain_name', '') or config.get('host', '')
|
|
33
36
|
self.auth_id = config['sasl_kerberos_service_name'] + '@' + kerberos_domain_name
|
|
34
|
-
if
|
|
35
|
-
self.gssapi_name = config['sasl_kerberos_name']
|
|
36
|
-
else:
|
|
37
|
+
if self.gssapi_name is None:
|
|
37
38
|
self.gssapi_name = gssapi.Name(self.auth_id, name_type=gssapi.NameType.hostbased_service).canonicalize(gssapi.MechType.kerberos)
|
|
38
39
|
self._client_ctx = gssapi.SecurityContext(name=self.gssapi_name, usage='initiate')
|
|
39
40
|
self._next_token = self._client_ctx.step(None)
|
|
@@ -43,9 +44,8 @@ class SaslMechanismGSSAPI(SaslMechanism):
|
|
|
43
44
|
# so mark is_done after the final auth_bytes are provided
|
|
44
45
|
# in practice we'll still receive a response when using SaslAuthenticate
|
|
45
46
|
# but not when using the prior unframed approach.
|
|
46
|
-
if self.
|
|
47
|
+
if self._is_authenticated:
|
|
47
48
|
self._is_done = True
|
|
48
|
-
self._is_authenticated = True
|
|
49
49
|
return self._next_token or b''
|
|
50
50
|
|
|
51
51
|
def receive(self, auth_bytes):
|
|
@@ -74,6 +74,13 @@ class SaslMechanismGSSAPI(SaslMechanism):
|
|
|
74
74
|
]
|
|
75
75
|
# add authorization identity to the response, and GSS-wrap
|
|
76
76
|
self._next_token = self._client_ctx.wrap(b''.join(message_parts), False).message
|
|
77
|
+
# We need to identify the last token in auth_bytes();
|
|
78
|
+
# we can't rely on client_ctx.complete because it becomes True after generating
|
|
79
|
+
# the second-to-last token (after calling .step(auth_bytes) for the final time)
|
|
80
|
+
# We could introduce an additional state variable (i.e., self._final_token),
|
|
81
|
+
# but instead we just set _is_authenticated. Since the plugin interface does
|
|
82
|
+
# not read is_authenticated() until after is_done() is True, this should be fine.
|
|
83
|
+
self._is_authenticated = True
|
|
77
84
|
|
|
78
85
|
def is_done(self):
|
|
79
86
|
return self._is_done
|
kafka/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '2.2.
|
|
1
|
+
__version__ = '2.2.10'
|
|
@@ -2,13 +2,13 @@ kafka/__init__.py,sha256=4dvHKZAxmD_4tfJ5wGcRV2X78vPcm8vsUoqceULevjA,1077
|
|
|
2
2
|
kafka/client_async.py,sha256=R8q_rRpG3RrYrRmcZo7XgO2oSdpLJATNcq8w-1vIJ_8,56878
|
|
3
3
|
kafka/cluster.py,sha256=N3_Al4We4ZhWzz6lVHy6SfqwDZfQy73iV7Qg4g4nxRs,16745
|
|
4
4
|
kafka/codec.py,sha256=8NZpnehzNrhSBIjzbPVSvyFbSeLAqEntE7BfVHu-_9I,10036
|
|
5
|
-
kafka/conn.py,sha256=
|
|
5
|
+
kafka/conn.py,sha256=_yP-pGwEbkDmeutMOZjVilQXAnF4PWF_CDc60qC3DuE,69488
|
|
6
6
|
kafka/errors.py,sha256=qX2Fp0qawU_HBNcZCwB7EDCmx3C2PehrETi6qSEJHmk,33290
|
|
7
7
|
kafka/future.py,sha256=ZQStbfUYIPJRrgMfAWxxjrIRVxsw4WCtSR0J0bkyGno,2847
|
|
8
8
|
kafka/socks5_wrapper.py,sha256=6woOaCTJXJ5e89_zdyW5BjOpyE4rCbYFH-kd-FeuPuk,9827
|
|
9
9
|
kafka/structs.py,sha256=SJGzmLdV21jZyQ7247k0WFy16UiusgTHK3I-e4qzI-E,3058
|
|
10
10
|
kafka/util.py,sha256=EnzCJuRkQ6Kh2lIdNwFKvT4PddkZ5bzop4ooGGIhe5g,4366
|
|
11
|
-
kafka/version.py,sha256=
|
|
11
|
+
kafka/version.py,sha256=lfEF2tRAjIf7jwdP4hzCfb5zYNcswMyGc2yOh47sA9k,23
|
|
12
12
|
kafka/admin/__init__.py,sha256=S_XxqyyV480_yXhttK79XZqNAmZyXRjspd3SoqYykE8,720
|
|
13
13
|
kafka/admin/acl_resource.py,sha256=ak_dUsSni4SyP0ORbSKenZpwTy0Ykxq3FSt_9XgLR8k,8265
|
|
14
14
|
kafka/admin/client.py,sha256=RabA8l8Im3iBEXgPVkiofNW6QyeatQHaymBWFZ8Sxkw,78929
|
|
@@ -23,12 +23,12 @@ kafka/benchmarks/record_batch_compose.py,sha256=CnUreNg1lUT0Qx9enmSr-THmBl9PjVMf
|
|
|
23
23
|
kafka/benchmarks/record_batch_read.py,sha256=vlFaWU2YWI379n_2M8qieb_S2uHUWKV0NquEYy5b-Ho,2184
|
|
24
24
|
kafka/benchmarks/varint_speed.py,sha256=s4CuvKgDZL-_zna5E3vM8RgHjhXuW6pcaO1z1WYZ_0Y,12585
|
|
25
25
|
kafka/consumer/__init__.py,sha256=NDdvtyuJgFyQZahqL9i5sYXGP6rOMIXWwHQEaZ1fCcs,122
|
|
26
|
-
kafka/consumer/fetcher.py,sha256=
|
|
27
|
-
kafka/consumer/group.py,sha256=
|
|
26
|
+
kafka/consumer/fetcher.py,sha256=5b-_4VsmQXrRd2Ul8LMZ93TZJHVEoYpmTPB6QcOMizw,69045
|
|
27
|
+
kafka/consumer/group.py,sha256=oieWNHM1NWiOZT8pasOLfFJAbmJEXJ4h7PgUtklxo_Q,58944
|
|
28
28
|
kafka/consumer/subscription_state.py,sha256=f_qJQMhTWQnUd_7lPj43gsagWSKGEmP4jpnEwA6s1Ec,23661
|
|
29
29
|
kafka/coordinator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
30
30
|
kafka/coordinator/base.py,sha256=NmHXyqoJZVXL2KhahXLCOH1zVx9gyTdhrt-_unxIAaE,54365
|
|
31
|
-
kafka/coordinator/consumer.py,sha256=
|
|
31
|
+
kafka/coordinator/consumer.py,sha256=le4bGbHfrDK4pperYXekPKzuZW576uXL324IOwS4Kmw,46348
|
|
32
32
|
kafka/coordinator/heartbeat.py,sha256=LeJJlwz1oUEOfEMIFT-R7ZOHBQ-b-luVKwmKyWxLfDo,3242
|
|
33
33
|
kafka/coordinator/protocol.py,sha256=wTaIOnUVbj0CKXZ82FktZo-zMRvOCk3hdQAoHJ62e3I,1041
|
|
34
34
|
kafka/coordinator/assignors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -107,7 +107,7 @@ kafka/record/memory_records.py,sha256=b7RFxvaQ93drXSk3o3_YB3FQlVoESoBlGj3Z5PD25n
|
|
|
107
107
|
kafka/record/util.py,sha256=LDajBWdYVetmXts_t9Q76CxEx7njgC9LnjMgz9yPEMM,3556
|
|
108
108
|
kafka/sasl/__init__.py,sha256=wUUGIKRe52J6Qekj7hSypg44vWTrkYsEdVafQC7cX5s,1106
|
|
109
109
|
kafka/sasl/abc.py,sha256=R0BZOk3AYEGyehiGbbg-LMRvFAlWZsh0fBiESgUpBYw,657
|
|
110
|
-
kafka/sasl/gssapi.py,sha256=
|
|
110
|
+
kafka/sasl/gssapi.py,sha256=HqN9yikeT75zvq42SxuKhsH1WAMT3ZaT9j-E6LAwggw,4591
|
|
111
111
|
kafka/sasl/msk.py,sha256=ndUZqPTdgItptiRimVlUAGuFZz1cerQc1KufYMIcPkg,7684
|
|
112
112
|
kafka/sasl/oauth.py,sha256=dh87tVi-dlS5lIzgYsC4m7IXUhlLdejaMb9Ua6oYaB0,3425
|
|
113
113
|
kafka/sasl/plain.py,sha256=PMfoWT856wx6nF_LhpfPKEnD7BRNx5l6rDhAqxBnMWU,1317
|
|
@@ -120,7 +120,7 @@ kafka/vendor/enum34.py,sha256=-u-lxAiJMt6ru4Do7NUDY9OpeWkYJMksb2xengJawFE,31204
|
|
|
120
120
|
kafka/vendor/selectors34.py,sha256=gxejLO4eXf8mRSGXaQiknPig3GdX1rtsZiYOQJVuAy8,20594
|
|
121
121
|
kafka/vendor/six.py,sha256=lLBa9_HrANP5BMZ7twEzg1M3wofwPmXyptuWmHX0brY,34826
|
|
122
122
|
kafka/vendor/socketpair.py,sha256=Fi3PoY1Okkppab720wFk1BhHXyjcw7hi5DwhqrYZH2Y,2737
|
|
123
|
-
kafka_python-2.2.
|
|
124
|
-
kafka_python-2.2.
|
|
125
|
-
kafka_python-2.2.
|
|
126
|
-
kafka_python-2.2.
|
|
123
|
+
kafka_python-2.2.10.dist-info/METADATA,sha256=LNkDuppqocj9ondpnWf2PmlMQkYN5w-K8nnozxZKKmQ,9952
|
|
124
|
+
kafka_python-2.2.10.dist-info/WHEEL,sha256=egKm5cKfE6OqlHwodY8Jjp4yqZDBXgsj09UsV5ojd_U,109
|
|
125
|
+
kafka_python-2.2.10.dist-info/top_level.txt,sha256=IivJz7l5WHdLNDT6RIiVAlhjQzYRwGqBBmKHZ7WjPeM,6
|
|
126
|
+
kafka_python-2.2.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|