Issue #761 duplicate

FileSession lock acquisition masks errors, hangs server

Anonymous created an issue

The FileSession acquire_lock method loops indefinitely if an error occurs while attempting to open/create the lockfile. The error cause is not checked, assumed to be an already existing lockfile. This masks any other error and hangs cherrypy.

I propose: {{{ import errno ... def acquire_lock(self, path=None): print "_acquire_lock" if path is None: path = self._get_file_path() path += self.LOCK_SUFFIX while True: try: lockfd = os.open(path, os.O_CREAT|os.O_WRONLY|os.O_EXCL) except OSError, e: if e.errno == errno.EEXIST: time.sleep(0.1) else: raise else: os.close(lockfd) break self.locked = True }}}

Reported by anorth@deepgreylabs.com

Comments (2)

  1. Log in to comment