Python warpper of the Windows job feature, replacement of the resource library
Project description
LibJob
LibJob is the python wrapper of windows's job
feature, which could replace resource
easily.
Using Example & Compares(when applying 100MB memory limit to given two processes):
by resource
standard library:
curlimit = resource.prlimit(pid1, resource.RLIMIT_VMEM)
resource.prlimit(pid1, resource.RLIMIT_MEMLOCK, (100 * 1024 * 1024, curlimit[1]))
curlimit = resource.prlimit(pid2, resource.RLIMIT_VMEM)
resource.prlimit(pid2, resource.RLIMIT_MEMLOCK, (100 * 1024 * 1024, curlimit[1]))
by using pywin32
job = win32job.CreateJobObject(None, "")
extended_info = win32job.QueryInformationJobObject(job, win32job.JobObjectExtendedLimitInformation)
extended_info["ProcessMemoryLimit"] = 100 * 1024 * 1024
extended_info["BasicLimitInformation"]["LimitFlags"] |= win32job.JOB_OBJECT_LIMIT_PROCESS_MEMORY
win32job.SetInformationJobObject(job, win32job.JobObjectExtendedLimitInformation, extended_info)
proc = win32api.OpenProcess(win32con.PROCESS_SET_QUOTA | win32con.PROCESS_TERMINATE, False, pid1)
win32job.AssignProcessToJobObject(job, proc)
proc = win32api.OpenProcess(win32con.PROCESS_SET_QUOTA | win32con.PROCESS_TERMINATE, False, pid2)
win32job.AssignProcessToJobObject(job, proc)
by using libjob
job = libjob.Job()
job.process_memory_limit = 100 * 1024 * 1024
job.assign(pid1)
job.assign(pid2)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
libjob-0.1.3.tar.gz
(20.9 kB
view details)
Built Distribution
libjob-0.1.3-py3-none-any.whl
(19.7 kB
view details)
File details
Details for the file libjob-0.1.3.tar.gz
.
File metadata
- Download URL: libjob-0.1.3.tar.gz
- Upload date:
- Size: 20.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f54c6f5038b6e2bd366dc4018578deb7c3391e88293fde71d55f86fc268fbab |
|
MD5 | b3141738fa2e4686b03424d9b24242e7 |
|
BLAKE2b-256 | fcf0a89ef658f837dee667dda5df6bbd623292776b192c394c5f8016523c33f3 |
File details
Details for the file libjob-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: libjob-0.1.3-py3-none-any.whl
- Upload date:
- Size: 19.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a1daa4aa20e9d513d502ff48f91ac4e652e76ab6e167155668204ebddf9d1bb |
|
MD5 | 446fb3dbfbfdf1848c2385f197293dfb |
|
BLAKE2b-256 | ce35abc28be3721813022712a510f32e5402eaa1d795d2206c9489150bf70331 |