@@ -449,10 +449,14 @@ def start(self):
449
449
self .stopped = False
450
450
self .consumer = ck .Consumer (self .cpars )
451
451
self .consumer .subscribe (self .topics )
452
- weakref .finalize (self , lambda consumer = self .consumer : _close_consumer (consumer ))
452
+ weakref .finalize (
453
+ self , lambda consumer = self .consumer : _close_consumer (consumer )
454
+ )
453
455
tp = ck .TopicPartition (self .topics [0 ], 0 , 0 )
454
456
455
- # blocks for consumer thread to come up
457
+ # blocks for consumer thread to come up and invoke poll to
458
+ # establish connection with broker to fetch oauth token for kafka
459
+ self .consumer .poll (timeout = 1 )
456
460
self .consumer .get_watermark_offsets (tp )
457
461
self .loop .add_callback (self .poll_kafka )
458
462
@@ -479,7 +483,8 @@ def __init__(self, topic, consumer_params, poll_interval='1s',
479
483
max_batch_size = 10000 , keys = False ,
480
484
engine = None , ** kwargs ):
481
485
self .consumer_params = consumer_params
482
- # Override the auto-commit config to enforce custom streamz checkpointing
486
+ # Override the auto-commit config to enforce custom streamz
487
+ # checkpointing
483
488
self .consumer_params ['enable.auto.commit' ] = 'false'
484
489
if 'auto.offset.reset' not in self .consumer_params .keys ():
485
490
consumer_params ['auto.offset.reset' ] = 'latest'
@@ -587,7 +592,9 @@ def start(self):
587
592
self .stopped = False
588
593
tp = ck .TopicPartition (self .topic , 0 , 0 )
589
594
590
- # blocks for consumer thread to come up
595
+ # blocks for consumer thread to come up and invoke poll to establish
596
+ # connection with broker to fetch oauth token for kafka
597
+ self .consumer .poll (timeout = 1 )
591
598
self .consumer .get_watermark_offsets (tp )
592
599
self .loop .add_callback (self .poll_kafka )
593
600
0 commit comments