def stop(self):
<EOL>try:<EOL><INDENT>pf = file(self.pidfile, '<STR_LIT:r>')<EOL>pid = int(pf.read().strip())<EOL>pf.close()<EOL><DEDENT>except IOError:<EOL><INDENT>pid = None<EOL><DEDENT>if not pid:<EOL><INDENT>sys.stderr.write(<EOL>"<STR_LIT>".format(<EOL>self.pidfile))<EOL>return  <EOL><DEDENT>try:<EOL><INDENT>while <NUM_LIT:1>:<EOL><INDENT>os.kill(pid, SIGTERM)<EOL>time.sleep(<NUM_LIT:0.1>)<EOL><DEDENT><DEDENT>except OSError as err:<EOL><INDENT>err = str(err)<EOL>if err.find("<STR_LIT>") > <NUM_LIT:0>:<EOL><INDENT>if os.path.exists(self.pidfile):<EOL><INDENT>os.remove(self.pidfile)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>print(str(err))<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT><DEDENT>
Stop the daemon