Skip to main content

k3cgrouparch

Action-CI Documentation Status Package

This lib is used to set up cgroup directory tree according to configuration saved in zookeeper, and add pid to cgroup accordingly.

k3cgrouparch is a component of pykit3 project: a python3 toolkit set.

Name

cgrouparch

A python lib used to build cgroup directory tree, add set cgroup pid.

Status

This library is considered production ready.

It supports only cgroup v1. It manages the cpu and blkio subsystems in <cgroup_dir>/<subsystem>, such as /sys/fs/cgroup/cpu. It uses v1 files such as cpu.shares, blkio.weight and tasks. A host that mounts only the cgroup v2 unified hierarchy has none of these files.

Description

This lib is used to set up cgroup directory tree according to configuration saved in zookeeper, and add pid to cgroup accordingly.

Install

pip install k3cgrouparch

Synopsis

# {
#     'cpu': {
#         'sub_cgroup': {
#             'test_cgroup_a': {
#                 'conf': {
#                     'share': 1024,
#                 },
#             },
#             'test_cgroup_b': {
#                 'conf': {
#                     'share': 100,
#                 },
#                 'sub_cgroup': {
#                     'test_cgroup_b_sub1': {
#                         'conf': {
#                             'share': 200,
#                         },
#                     },
#                 },
#             },
#         },
#     },
# }

from k3cgrouparch import manager


def get_cgroup_pid_file(cgroup_name):
    if cgroup_name == "test_cgroup_a":
        return ["/tmp/test.pid"]
    # ...


def get_zk_host():
    return "127.0.0.1:2181,1.2.3.4:2181"


argkv = {
    "cgroup_dir": "/sys/fs/cgroup",
    "get_cgroup_pid_file": get_cgroup_pid_file,
    "get_zk_host": get_zk_host,
    "zk_prefix": "/cluser_a/service_rank",
    "zk_auth_data": [("digest", "super:123456")],
    "communicate_ip": "127.0.0.1",
    "communicate_port": "3344",
}

manager.run(**argkv)

argkv = {
    "cgroup_dir": "/sys/fs/cgroup",
    "get_zk_host": get_zk_host,
    "zk_prefix": "/cluser_a/service_rank",
    "zk_auth_data": [("digest", "super:123456")],
}
cgexec_arg = manager.get_cgexec_arg(["test_cgroup_a"], **argkv)

# return like:
# {
#     'test_cgroup_a': '-g cpu:test_cgroup_a',
# }

Author

Zhang Yanpo (张炎泼) drdr.xp@gmail.com

Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Zhang Yanpo (张炎泼) drdr.xp@gmail.com

Metadata

Release files for k3cgrouparch 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for k3cgrouparch 0.1.5
File Size Uploaded
k3cgrouparch-0.1.5.tar.gz 12.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for k3cgrouparch 0.1.5
File Interpreter ABI Platform
k3cgrouparch-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 24.5 kB

Release files / k3cgrouparch-0.1.5.tar.gz

Download URL k3cgrouparch-0.1.5.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b7c379b0244bde4d8c07ebd8f392e136e07ca588a87480ed8ca9a5203da178d1
BLAKE2b-256 checksum
How to use checksums
c386c33aad3a5b10132cce333a14408bf94ea5014a9f2a3f2b9c4797ae0a935b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / k3cgrouparch-0.1.5-py3-none-any.whl

Download URL k3cgrouparch-0.1.5-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9be09d71c60a722df5c15be9c820fc566328b82f85adf7a7154522909f2c0432
BLAKE2b-256 checksum
How to use checksums
3ae0e8b45f5721f2023a8b3e1265d329d5db6b13557feccec45b1201d2be7362
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release history Release notifications | RSS feed

0.1.7

2 release files

0.1.6

2 release files

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page