def example_create_partitions(a, topics):
    """ create partitions """

    new_parts = [NewPartitions(topic, int(new_total_count)) for
                 topic, new_total_count in zip(topics[0::2], topics[1::2])]

    # Try switching validate_only to True to only validate the operation
    # on the broker but not actually perform it.
    fs = a.create_partitions(new_parts, validate_only=False)

    # Wait for operation to finish.
    for topic, f in fs.items():
        try:
            f.result()  # The result itself is None
            print("Additional partitions created for topic {}".format(topic))
        except Exception as e:
            print("Failed to add partitions to topic {}: {}".format(topic, e))
def example_create_partitions ( a , topics ) : new_parts = [ NewPartitions ( topic , int ( new_total_count ) ) for topic , new_total_count in zip ( topics [ 0 : : 2 ] , topics [ 1 : : 2 ] ) ] fs = a . create_partitions ( new_parts , validate_only = False ) for topic , f in fs . items ( ) : try : f . result ( ) print ( "Additional partitions created for topic {}" . format ( topic ) ) except Exception as e : print ( "Failed to add partitions to topic {}: {}" . format ( topic , e ) )
create partitions