def sysctlTestAndSet(name, limit):
 if ('/' not in name):
  name = ('/proc/sys/' + name.replace('.', '/'))
 with open(name, 'r') as readFile:
  oldLimit = readFile.readline()
  if isinstance(limit, int):
   if (int(oldLimit) < limit):
    with open(name, 'w') as writeFile:
     writeFile.write(('%d' % limit))
  else:
   with open(name, 'w') as writeFile:
    writeFile.write(limit)

def sysctlTestAndSet ( name , limit ) : if ( '/' not in name ) : name = ( '/proc/sys/' + name . replace ( '.' , '/' ) ) with open ( name , 'r' ) as readFile : oldLimit = readFile . readline ( ) if isinstance ( limit , int ) : if ( int ( oldLimit ) < limit ) : with open ( name , 'w' ) as writeFile : writeFile . write ( ( '%d' % limit ) ) else : with open ( name , 'w' ) as writeFile : writeFile . write ( limit )
helper function to set sysctl limits .