7 """Helper to max soft resource limits to the hard ones."""
9 from AthenaCommon.Logging
import logging
15 __author__ =
'Grigori Rybkine (Grigori.Rybkine@cern.ch)'
17 __all__ = [
'SetMaxLimits' ]
19 log = logging.getLogger(
'ResourceLimits' )
24 soft, hard = resource.getrlimit( what )
25 if soft < hard
or ( hard == -1
and soft != hard ):
26 log.debug(
'setting soft %s limit to %s (was: %s)', descr,
27 hard == -1
and 'unlimited' or str(hard),
28 soft == -1
and 'unlimited' or str(soft), )
30 resource.setrlimit( what, (hard,hard) )
32 if what != resource.RLIMIT_AS
or hard != -1:
raise
34 if platform.architecture()[0] !=
'32bit':
raise
35 if platform.machine()
in [
'i386',
'i486',
'i586',
'i686']:
raise
44 log.debug(
'setting soft %s limit to %s (was: %s)', descr,
47 resource.setrlimit( resource.RLIMIT_AS, (hard,hard) )
51 log.debug(
'set soft %s limit to %s (was: %s)', descr,
59 _maxout( resource.RLIMIT_AS,
'address space' )
60 _maxout( resource.RLIMIT_RSS,
'resident state' )
61 except (ValueError,resource.error)
as e:
62 log.warning(
'failed to set max resource limits (%s)',
str(e) )