from datetime import datetime


def gen_unique_task_id(prefix=None):
    """
    unique id generator for various DLS tasks
    :param prefix: prefix for task type
    :return: unique string index (list of indexes can be sorted by date)
    """
    task_id = datetime.now().strftime('%Y%m%d-%H%M%S-%f')
    if prefix is not None:
        ret_task_id = '%s-%s' % (prefix, task_id)
    else:
        ret_task_id = task_id
    return ret_task_id