Return a Cgroup object with the cgroups of the current process.
    Note that it is not guaranteed that all subsystems are available
    in the returned object, as a subsystem may not be mounted.
    Check with "subsystem in <instance>" before using.
    A subsystem may also be present but we do not have the rights to create
    child cgroups, this can be checked with require_subsystem().
    @param cgroup_paths: If given, use this instead of reading /proc/self/cgroup.

def find_my_cgroups(cgroup_paths=None):
    """
    Return a Cgroup object with the cgroups of the current process.
    Note that it is not guaranteed that all subsystems are available
    in the returned object, as a subsystem may not be mounted.
    Check with "subsystem in <instance>" before using.
    A subsystem may also be present but we do not have the rights to create
    child cgroups, this can be checked with require_subsystem().
    @param cgroup_paths: If given, use this instead of reading /proc/self/cgroup.
    """
    logging.debug('Analyzing /proc/mounts and /proc/self/cgroup for determining cgroups.')
    if cgroup_paths is None:
        my_cgroups = dict(_find_own_cgroups())
    else:
        my_cgroups = dict(_parse_proc_pid_cgroup(cgroup_paths))

    cgroupsParents = {}
    for subsystem, mount in _find_cgroup_mounts():
        # Ignore mount points where we do not have any access,
        # e.g. because a parent directory has insufficient permissions
        # (lxcfs mounts cgroups under /run/lxcfs in such a way).
        if os.access(mount, os.F_OK):
            cgroupPath = os.path.join(mount, my_cgroups[subsystem])
            if (not os.access(cgroupPath, os.W_OK) and
                    os.access(os.path.join(cgroupPath, CGROUP_FALLBACK_PATH), os.W_OK)):
                cgroupPath = os.path.join(cgroupPath, CGROUP_FALLBACK_PATH)
            cgroupsParents[subsystem] = cgroupPath

    return Cgroup(cgroupsParents)