def purge_orphaned_workflow_executions(logger):
    """
    Purge workflow executions that are idled and identified as orphans.
    """
    # Cancel workflow executions that are identified as orphans. The workflow executions are
    # marked as canceled instead of failed because error handling during normal operation
    # failed and the system does not know what state the workflow execution is in. A failed
    # workflow execution can be rerun from failed task(s). Since we do not know what state
    # the workflow execution is in because correct data may not be recorded in the database
    # as a result of the original failure, the garbage collection routine here cancels
    # the workflow execution so it cannot be rerun from failed task(s).
    for ac_ex_db in workflow_service.identify_orphaned_workflows():
        lv_ac_db = LiveAction.get(id=ac_ex_db.liveaction["id"])
        action_service.request_cancellation(lv_ac_db, None)

    Purge workflow executions that are idled and identified as orphans.
    
st2common/st2common/garbage_collection/executions.py