def islocked(self):
        '''Check if we already have a lock'''
        try:
            lock = self._readlock()
            os.kill(int(lock['pid']), 0)
            return (lock['host'] == self.host)
        except:
            return False
Check if we already have a lock
recipes/Python/498171_Simple_lockfile_detect_previous_instances/recipe-498171.py