Skip to content Skip to sidebar Skip to footer

What Is Python's Equivalent To 'ulimit'?

I'm trying to implement a check on system resources for the current shell (basically everything in ulimit) in Python to see if enough resources can be allocated. I've found the res

Solution 1:

Use resource.getrlimit(). If there's no constant in the resource package, look it up in /usr/include/bits/resource.h:

$ grep RLIMIT_MSGQUEUE /usr/include/bits/resource.h
  __RLIMIT_MSGQUEUE = 12,
#define RLIMIT_MSGQUEUE __RLIMIT_MSGQUEUE

Then you can define the constant yourself:

import resource
RLIMIT_MSGQUEUE = 12print(resource.getrlimit(RLIMIT_MSGQUEUE))

Post a Comment for "What Is Python's Equivalent To 'ulimit'?"