Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • pypy pypy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 676
    • Issues 676
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 13
    • Merge requests 13
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

April 05-07 - Mercurial Paris Conference 2023 - One day of workshop dedicated to Heptapod and Mercurial usage and workflow. There are still places available for both workshops and talks!

  • PyPyPyPy
  • pypypypy
  • Merge requests
  • !770

WIP: add resource.prlimit() (added in CPython 3.4)

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged cptpcrd requested to merge branch/cptpcrd-resource-prlimit into branch/default Oct 28, 2020
  • Overview 24
  • Commits 4
  • Pipelines 2
  • Changes 4

resource.prlimit was added in Python 3.4, but PyPy doesn't have it. This PR adds it.

Background

For anyone who's unfamiliar with prlimit(), it's a Linux syscall that allows viewing/manipulating the resource limits of arbitrary processes, not just the current process as with getrlimit() and setrlimit(). It also combines the functionality of getrlimit() and setrlimit(), allowing you to set new resource limits while also retrieving the previous resource limits.

Note on compatibility: FreeBSD has a very similar interface to manipulate resource limits (it's an undocumented sysctl()). However, CPython doesn't use that to provide resource.prlimit() on FreeBSD, so I didn't do that here either.

Things that need to be addressed before this PR can be merged

  • I'm not sure if my use of ffi.cdef() in lib_pypy/_resource_build.py is the proper way to add OS-specific headers. (I actually haven't tested that commit yet; I'm currently rebuilding and I'll comment if it fails.)
  • The getrlimit()/setrlimit() tests are fairly thin (and comments in the testing code admit as much). I added some more extensive tests for prlimit(), but I'm not sure if those are too restrictive and might cause breakage on some systems. (Or should they be more extensive?)
  • CPython's resource.prlimit() doesn't allow passing None for the limits argument; the only way to do get the resource limits without changing them is to omit the limits argument altogether. My current implementation treats limits=None the same as if it were omitted altogether; should that be changed to match CPython's behavior?

Disclaimers

  1. I'm a new contributor; I'm not sure if what I'm doing meets PyPy's conventions. Mostly I just added the implementation/tests alongside getrlimit()/setrlimit().
  2. I'm used to Git, and I'm muddling my way through using Mercurial. Please let me know if I did anything wrong setting up this PR.
Edited Oct 28, 2020 by cptpcrd
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: branch/cptpcrd-resource-prlimit