Event handler

def handle(client_message, handle_event_partition_lost=None, to_object=None):
    """ Event handler """
    message_type = client_message.get_message_type()
    if message_type == EVENT_PARTITIONLOST and handle_event_partition_lost is not None:
        partition_id = client_message.read_int()
        lost_backup_count = client_message.read_int()
        source = None
        if not client_message.read_bool():
            source = AddressCodec.decode(client_message, to_object)
        handle_event_partition_lost(partition_id=partition_id, lost_backup_count=lost_backup_count, source=source)