def _memory_watchdog(start_evt, finish_evt, period=<NUM_LIT>):
<EOL>try:<EOL><INDENT>page_size = os.sysconf('<STR_LIT>')<EOL><DEDENT>except (ValueError, AttributeError):<EOL><INDENT>try:<EOL><INDENT>page_size = os.sysconf('<STR_LIT>')<EOL><DEDENT>except (ValueError, AttributeError):<EOL><INDENT>page_size = <NUM_LIT><EOL><DEDENT><DEDENT>procfile = '<STR_LIT>'.format(pid=os.getpid())<EOL>try:<EOL><INDENT>f = open(procfile, '<STR_LIT:rb>')<EOL><DEDENT>except IOError as e:<EOL><INDENT>warnings.warn('<STR_LIT>'.format(e),<EOL>RuntimeWarning)<EOL>sys.stderr.flush()<EOL>return<EOL><DEDENT>with f:<EOL><INDENT>start_evt.set()<EOL>old_data = -<NUM_LIT:1><EOL>while not finish_evt.wait(period):<EOL><INDENT>f.seek(<NUM_LIT:0>)<EOL>statm = f.read().decode('<STR_LIT:ascii>')<EOL>data = int(statm.split()[<NUM_LIT:5>])<EOL>if data != old_data:<EOL><INDENT>old_data = data<EOL>print("<STR_LIT>"<EOL>.format(data=data * page_size / (<NUM_LIT> ** <NUM_LIT:3>)))<EOL><DEDENT><DEDENT><DEDENT>
A function which periodically watches the process' memory consumption
    and prints it out.