def deserialize_utf8(value, partition_key):
    """A deserializer accepting bytes arguments and returning utf-8 strings

    Can be used as `pykafka.simpleconsumer.SimpleConsumer(deserializer=deserialize_utf8)`,
    or similarly in other consumer classes
    """
    # allow UnicodeError to be raised here if the decoding fails
    if value is not None:
        value = value.decode('utf-8')
    if partition_key is not None:
        partition_key = partition_key.decode('utf-8')
    return value, partition_key