Skip to main content

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


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.0.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

libjob-0.1.0-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file libjob-0.1.0.tar.gz.

File metadata

  • Download URL: libjob-0.1.0.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.1

File hashes

Hashes for libjob-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bac8beee570fbee7d972e8fa0cfdfabfbadf003067ed298ff71375cc739b406f
MD5 d70cf37244715105ee94d940e7e7aa6c
BLAKE2b-256 48360c52c77ce9731406c1026730d3b8bf5be1eba6bc4849d3e5b04e144ba52d

See more details on using hashes here.

File details

Details for the file libjob-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: libjob-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.1

File hashes

Hashes for libjob-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 48a9ba8838cf7ee4c818e435cb433577d6e8e521a572a7e4d20e98b1aac19500
MD5 8efa227cab6ebcecfb164d3525870b7e
BLAKE2b-256 a094bd2ab6616a49fcf186b998b011720921dd23711a0b0c50091b89bf42ee8a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page