Python resource.RLIMIT_CPU Examples
The following are 5
code examples of resource.RLIMIT_CPU().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
resource
, or try the search function
.
Example #1
Source File: timeout.py From Yuki-Chan-The-Auto-Pentest with MIT License | 6 votes |
def limitedTime(second, func, *args, **kw): second = fixTimeout(second) old_alarm = signal(SIGXCPU, signalHandler) current = getrlimit(RLIMIT_CPU) try: setrlimit(RLIMIT_CPU, (second, current[1])) return func(*args, **kw) finally: setrlimit(RLIMIT_CPU, current) signal(SIGXCPU, old_alarm)
Example #2
Source File: util.py From BugZoo with MIT License | 6 votes |
def report_resource_limits(logger: logging.Logger) -> None: resources = [ ('CPU time (seconds)', resource.RLIMIT_CPU), ('Heap size (bytes)', resource.RLIMIT_DATA), ('Num. process', resource.RLIMIT_NPROC), ('Num. files', resource.RLIMIT_NOFILE), ('Address space', resource.RLIMIT_AS), ('Locked address space', resource.RLIMIT_MEMLOCK) ] resource_limits = [ (name, resource.getrlimit(res)) for (name, res) in resources ] resource_s = '\n'.join([ '* {}: {}'.format(res, lim) for (res, lim) in resource_limits ]) logger.info("resource limits:\n%s", indent(resource_s, 2))
Example #3
Source File: timeout.py From ITWSV with MIT License | 5 votes |
def limitedTime(second, func, *args, **kw): second = fixTimeout(second) old_alarm = signal(SIGXCPU, signalHandler) current = getrlimit(RLIMIT_CPU) try: setrlimit(RLIMIT_CPU, (second, current[1])) return func(*args, **kw) finally: setrlimit(RLIMIT_CPU, current) signal(SIGXCPU, old_alarm)
Example #4
Source File: test_processutils.py From oslo.concurrency with Apache License 2.0 | 5 votes |
def test_cpu_time(self): time = self.soft_limit(resource.RLIMIT_CPU, 1, 1024) prlimit = processutils.ProcessLimits(cpu_time=time) self.check_limit(prlimit, 'RLIMIT_CPU', prlimit.cpu_time)
Example #5
Source File: timeout.py From EasY_HaCk with Apache License 2.0 | 5 votes |
def limitedTime(second, func, *args, **kw): second = fixTimeout(second) old_alarm = signal(SIGXCPU, signalHandler) current = getrlimit(RLIMIT_CPU) try: setrlimit(RLIMIT_CPU, (second, current[1])) return func(*args, **kw) finally: setrlimit(RLIMIT_CPU, current) signal(SIGXCPU, old_alarm)