ATLAS Offline Software
Loading...
Searching...
No Matches
python.ResourceLimits Namespace Reference

Functions

 _maxout (what, descr)
 private helper --------------------------------------------------------—
 _max_32bit_address_space (soft, descr)
 SetMaxLimits ()
 max out soft resource limits to hard ones -----------------------------—

Variables

str __version__ = '1.2.1'
 data ------------------------------------------------------------------—
str __author__ = 'Grigori Rybkine (Grigori.Rybkine@cern.ch)'
list __all__ = [ 'SetMaxLimits' ]
 log = logging.getLogger( 'ResourceLimits' )

Detailed Description

Helper to max soft resource limits to the hard ones.

Function Documentation

◆ _max_32bit_address_space()

python.ResourceLimits._max_32bit_address_space ( soft,
descr )
protected

Definition at line 38 of file ResourceLimits.py.

38def _max_32bit_address_space( soft, descr ):
39 MAX_AS = 2**32
40 _64MB = 64*1024*1024
41 hard = MAX_AS
42 while hard > soft:
43 try:
44 log.debug( 'setting soft %s limit to %s (was: %s)', descr,
45 str(hard),
46 str(soft), )
47 resource.setrlimit( resource.RLIMIT_AS, (hard,hard) )
48 except ValueError:
49 hard -= _64MB
50 else:
51 log.debug( 'set soft %s limit to %s (was: %s)', descr,
52 str(hard),
53 str(soft), )
54 return
55

◆ _maxout()

python.ResourceLimits._maxout ( what,
descr )
protected

private helper --------------------------------------------------------—

Definition at line 23 of file ResourceLimits.py.

23def _maxout( what, descr ):
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), )
29 try:
30 resource.setrlimit( what, (hard,hard) )
31 except ValueError:
32 if what != resource.RLIMIT_AS or hard != -1: raise
33 import platform
34 if platform.architecture()[0] != '32bit': raise
35 if platform.machine() in ['i386', 'i486', 'i586', 'i686']: raise
36 _max_32bit_address_space( soft, descr )
37

◆ SetMaxLimits()

python.ResourceLimits.SetMaxLimits ( )

max out soft resource limits to hard ones -----------------------------—

Definition at line 57 of file ResourceLimits.py.

57def SetMaxLimits():
58 try:
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) )
63

Variable Documentation

◆ __all__

list python.ResourceLimits.__all__ = [ 'SetMaxLimits' ]
private

Definition at line 17 of file ResourceLimits.py.

◆ __author__

str python.ResourceLimits.__author__ = 'Grigori Rybkine (Grigori.Rybkine@cern.ch)'
private

Definition at line 15 of file ResourceLimits.py.

◆ __version__

str python.ResourceLimits.__version__ = '1.2.1'
private

data ------------------------------------------------------------------—

Definition at line 14 of file ResourceLimits.py.

◆ log

python.ResourceLimits.log = logging.getLogger( 'ResourceLimits' )

Definition at line 19 of file ResourceLimits.py.