def run_recipe_timed(task, recipe, rinput):
    """Run the recipe and count the time it takes."""
    _logger.info('running recipe')
    now1 = datetime.datetime.now()
    task.state = 1
    task.time_start = now1
    #
    result = recipe(rinput)
    _logger.info('result: %r', result)
    task.result = result
    #
    now2 = datetime.datetime.now()
    task.state = 2
    task.time_end = now2
    return task
Run the recipe and count the time it takes.