Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Ticket #761 (defect)

Opened 9 months ago

FileSession lock acquisition masks errors, hangs server

Status: new

Reported by: anorth@deepgreylabs.com Assigned to: rdelon
Priority: normal Milestone:
Component: sessions Keywords:
Cc:

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

Hosted by WebFaction

Log in as guest/cpguest to create tickets