@memoize
def set_scputimes_ntuple(procfs_path):
 global scputimes
 with open_binary(('%s/stat' % procfs_path)) as f:
  values = f.readline().split()[1:]
 fields = ['user', 'nice', 'system', 'idle', 'iowait', 'irq', 'softirq']
 vlen = len(values)
 if (vlen >= 8):
  fields.append('steal')
 if (vlen >= 9):
  fields.append('guest')
 if (vlen >= 10):
  fields.append('guest_nice')
 scputimes = namedtuple('scputimes', fields)
 return scputimes

@ memoize def set_scputimes_ntuple ( procfs_path ) : global scputimes with open_binary ( ( '%s/stat' % procfs_path ) ) as f : values = f . readline ( ) . split ( ) [ 1 : ] fields = [ 'user' , 'nice' , 'system' , 'idle' , 'iowait' , 'irq' , 'softirq' ] vlen = len ( values ) if ( vlen >= 8 ) : fields . append ( 'steal' ) if ( vlen >= 9 ) : fields . append ( 'guest' ) if ( vlen >= 10 ) : fields . append ( 'guest_nice' ) scputimes = namedtuple ( 'scputimes' , fields ) return scputimes
return a namedtuple of variable fields depending on the cpu times available on this linux kernel version which may be: .