You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tools.py 549B

12345678910111213141516171819
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Thu Nov 24 12:09:33 2016
  4. @author: markus
  5. """
  6. # returns the PID and memory peak of python process itself
  7. def process_information ():
  8. result = {'memory_peak': 0, 'PID': None}
  9. fh = open('/proc/self/status')
  10. for line in fh:
  11. if (line.find ("VmPeak:") == 0):
  12. result["memory_peak"] = float (line.split (":")[1].strip ().split (" ")[0])
  13. if (line.find ("Pid:") == 0):
  14. result["PID"] = int (line.split (":")[1].strip ())
  15. fh.close ()
  16. return result