How to use the cgroupspy.trees function in cgroupspy

To help you get started, we’ve selected a few cgroupspy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apache / airflow / airflow / task / task_runner / cgroup_task_runner.py View on Github external
def _delete_cgroup(self, path):
        """
        Delete the specified cgroup.

        :param path: The path of the cgroup to delete.
        E.g. cpu/mygroup/mysubgroup
        """
        node = trees.Tree().root
        path_split = path.split("/")
        for path_element in path_split:
            name_to_node = {x.name.decode(): x for x in node.children}
            if path_element not in name_to_node:
                self.log.warning("Cgroup does not exist: %s", path)
                return
            else:
                node = name_to_node[path_element]
        # node is now the leaf node
        parent = node.parent
        self.log.debug("Deleting cgroup %s/%s", parent, node.name)
        parent.delete_cgroup(node.name.decode())
github KI-labs / kaos / backend / kaos_backend / clients / pachyderm.py View on Github external
def __init__(self, pps_client: PpsClient, pfs_client: PfsClient):
        """
        PachydermClient constructor.

        Args:
            pps_client (PpsClient): Pachyderm Pipeline System client
            pfs_client (PfsClient): Pachyderm File System client
        """
        self.pps_client = pps_client
        self.pfs_client = pfs_client
        self.pool = PoolManager()
        # TODO: expose
        self.max_workers = 20
        try:
            self.memory_limit = trees.Tree().get_node_by_path("/memory/").controller.limit_in_bytes
        except FileNotFoundError:
            # cgroups not found, probably running on local machine
            self.memory_limit = virtual_memory().available
        self.executor = ThreadPoolExecutor(max_workers=self.max_workers)