@@ -333,9 +333,9 @@ def verify_producer_performance(with_dr_cb=True):
333
333
bar .finish ()
334
334
335
335
print ('# producing %d messages (%.2fMb) took %.3fs: %d msgs/s, %.2f Mb/s' %
336
- (msgs_produced , bytecnt / (1024 * 1024 ), t_produce_spent ,
336
+ (msgs_produced , bytecnt / (1024 * 1024 ), t_produce_spent ,
337
337
msgs_produced / t_produce_spent ,
338
- (bytecnt / t_produce_spent ) / (1024 * 1024 )))
338
+ (bytecnt / t_produce_spent ) / (1024 * 1024 )))
339
339
print ('# %d temporary produce() failures due to backpressure (local queue full)' % msgs_backpressure )
340
340
341
341
print ('waiting for %d/%d deliveries' % (len (p ), msgs_produced ))
@@ -344,9 +344,9 @@ def verify_producer_performance(with_dr_cb=True):
344
344
t_delivery_spent = time .time () - t_produce_start
345
345
346
346
print ('# producing %d messages (%.2fMb) took %.3fs: %d msgs/s, %.2f Mb/s' %
347
- (msgs_produced , bytecnt / (1024 * 1024 ), t_produce_spent ,
347
+ (msgs_produced , bytecnt / (1024 * 1024 ), t_produce_spent ,
348
348
msgs_produced / t_produce_spent ,
349
- (bytecnt / t_produce_spent ) / (1024 * 1024 )))
349
+ (bytecnt / t_produce_spent ) / (1024 * 1024 )))
350
350
351
351
# Fake numbers if not using a dr_cb
352
352
if not with_dr_cb :
@@ -355,9 +355,9 @@ def verify_producer_performance(with_dr_cb=True):
355
355
dr .bytes_delivered = bytecnt
356
356
357
357
print ('# delivering %d messages (%.2fMb) took %.3fs: %d msgs/s, %.2f Mb/s' %
358
- (dr .msgs_delivered , dr .bytes_delivered / (1024 * 1024 ), t_delivery_spent ,
358
+ (dr .msgs_delivered , dr .bytes_delivered / (1024 * 1024 ), t_delivery_spent ,
359
359
dr .msgs_delivered / t_delivery_spent ,
360
- (dr .bytes_delivered / t_delivery_spent ) / (1024 * 1024 )))
360
+ (dr .bytes_delivered / t_delivery_spent ) / (1024 * 1024 )))
361
361
print ('# post-produce delivery wait took %.3fs' %
362
362
(t_delivery_spent - t_produce_spent ))
363
363
@@ -447,7 +447,7 @@ def print_wmark(consumer, topic_parts):
447
447
elif (msg .offset () % 4 ) == 0 :
448
448
offsets = c .commit (msg , asynchronous = False )
449
449
assert len (offsets ) == 1 , 'expected 1 offset, not %s' % (offsets )
450
- assert offsets [0 ].offset == msg .offset ()+ 1 , \
450
+ assert offsets [0 ].offset == msg .offset () + 1 , \
451
451
'expected offset %d to be committed, not %s' % \
452
452
(msg .offset (), offsets )
453
453
print ('Sync committed offset: %s' % offsets )
@@ -515,7 +515,7 @@ def my_on_revoke(consumer, partitions):
515
515
print ('on_revoke:' , len (partitions ), 'partitions:' )
516
516
for p in partitions :
517
517
print (' %s [%d] @ %d' % (p .topic , p .partition , p .offset ))
518
- consumer .unassign ()
518
+ consumer .unassign (partitions )
519
519
520
520
c .subscribe ([topic ], on_assign = my_on_assign , on_revoke = my_on_revoke )
521
521
@@ -559,8 +559,8 @@ def my_on_revoke(consumer, partitions):
559
559
if msgcnt > 0 :
560
560
t_spent = time .time () - t_first_msg
561
561
print ('%d messages (%.2fMb) consumed in %.3fs: %d msgs/s, %.2f Mb/s' %
562
- (msgcnt , bytecnt / (1024 * 1024 ), t_spent , msgcnt / t_spent ,
563
- (bytecnt / t_spent ) / (1024 * 1024 )))
562
+ (msgcnt , bytecnt / (1024 * 1024 ), t_spent , msgcnt / t_spent ,
563
+ (bytecnt / t_spent ) / (1024 * 1024 )))
564
564
565
565
print ('closing consumer' )
566
566
c .close ()
@@ -590,11 +590,11 @@ def verify_consumer_seek(c, seek_to_msg):
590
590
print ('seek: message at offset %d (epoch %d)' %
591
591
(msg .offset (), msg .leader_epoch ()))
592
592
assert msg .offset () == seek_to_msg .offset () and \
593
- msg .leader_epoch () == seek_to_msg .leader_epoch (), \
594
- ('expected message at offset %d (epoch %d), ' % (seek_to_msg .offset (),
595
- seek_to_msg .leader_epoch ())) + \
596
- ('not %d (epoch %d)' % (msg .offset (),
597
- msg .leader_epoch ()))
593
+ msg .leader_epoch () == seek_to_msg .leader_epoch (), \
594
+ ('expected message at offset %d (epoch %d), ' % (seek_to_msg .offset (),
595
+ seek_to_msg .leader_epoch ())) + \
596
+ ('not %d (epoch %d)' % (msg .offset (),
597
+ msg .leader_epoch ()))
598
598
break
599
599
600
600
@@ -643,7 +643,7 @@ def verify_batch_consumer():
643
643
elif (msg .offset () % 4 ) == 0 :
644
644
offsets = c .commit (msg , asynchronous = False )
645
645
assert len (offsets ) == 1 , 'expected 1 offset, not %s' % (offsets )
646
- assert offsets [0 ].offset == msg .offset ()+ 1 , \
646
+ assert offsets [0 ].offset == msg .offset () + 1 , \
647
647
'expected offset %d to be committed, not %s' % \
648
648
(msg .offset (), offsets )
649
649
print ('Sync committed offset: %s' % offsets )
@@ -697,7 +697,7 @@ def my_on_revoke(consumer, partitions):
697
697
print ('on_revoke:' , len (partitions ), 'partitions:' )
698
698
for p in partitions :
699
699
print (' %s [%d] @ %d' % (p .topic , p .partition , p .offset ))
700
- consumer .unassign ()
700
+ consumer .unassign (partitions )
701
701
702
702
c .subscribe ([topic ], on_assign = my_on_assign , on_revoke = my_on_revoke )
703
703
@@ -738,8 +738,8 @@ def my_on_revoke(consumer, partitions):
738
738
if msgcnt > 0 :
739
739
t_spent = time .time () - t_first_msg
740
740
print ('%d messages (%.2fMb) consumed in %.3fs: %d msgs/s, %.2f Mb/s' %
741
- (msgcnt , bytecnt / (1024 * 1024 ), t_spent , msgcnt / t_spent ,
742
- (bytecnt / t_spent ) / (1024 * 1024 )))
741
+ (msgcnt , bytecnt / (1024 * 1024 ), t_spent , msgcnt / t_spent ,
742
+ (bytecnt / t_spent ) / (1024 * 1024 )))
743
743
744
744
print ('closing consumer' )
745
745
c .close ()
@@ -1035,8 +1035,8 @@ def stats_cb(stats_json_str):
1035
1035
if msgcnt > 0 :
1036
1036
t_spent = time .time () - t_first_msg
1037
1037
print ('%d messages (%.2fMb) consumed in %.3fs: %d msgs/s, %.2f Mb/s' %
1038
- (msgcnt , bytecnt / (1024 * 1024 ), t_spent , msgcnt / t_spent ,
1039
- (bytecnt / t_spent ) / (1024 * 1024 )))
1038
+ (msgcnt , bytecnt / (1024 * 1024 ), t_spent , msgcnt / t_spent ,
1039
+ (bytecnt / t_spent ) / (1024 * 1024 )))
1040
1040
1041
1041
print ('closing consumer' )
1042
1042
c .close ()
0 commit comments