def stop (self):

        '''
            Stop the daemon
        '''

        if self.verbose >= 1:
            print 'Stopping...'

        # Get the pid from the pidfile
        pid = self.get_pid()

        if not pid:

            message = 'pidfile %s does not exist. Not running?\n'
            sys.stderr.write(message % self.pidfile)

            # Just to be sure. A ValueError might occur if the PID file is
            # empty but does actually exist
            if os.path.exists(self.pidfile):
                os.remove(self.pidfile)

            return  # Not an error in a restart

        # Try killing the daemon process
        try:

            i = 0
            while 1:

                os.kill(pid, signal.SIGTERM)
                time.sleep(0.1)
                i += 1
                if i % 10 == 0:
                    os.kill(pid, signal.SIGHUP)

        except __HOLE__, err:

            err = str(err)
            if err.find('No such process') > 0:
                if os.path.exists(self.pidfile):
                    os.remove(self.pidfile)

            else:
                print str(err)
                sys.exit(1)

        if self.verbose >= 1:
            print 'Stopped'
dataset/ETHPy150Open leonjza/hogar/hogar/Utils/Daemon.py/Daemon.stop