PIDLock is using relative directories

Issue #197 resolved
MarkLIC created an issue

http://code.google.com/p/modwsgi/wiki/ApplicationIssues says that "... an application should never assume that it can use relative path names for accessing the filesystem. All paths used should always be absolute path names."

But DaemonLock.makelock in pidlock.py is giving me IOErrors about being unable to create a task_abcd123 file when I try to view a page's summary (sometimes). AFAICT this is because I have (poorly) configured mod_wsgi and RhodeCode is using / as the working directory.

In other words, I'm having the same issue as http://groups.google.com/group/rhodecode/browse_thread/thread/31610c3b126755ae but the fix was not detailed in that thread and I'm at a loss currently on how to fix it.

Comments (4)

  1. MarkLIC reporter

    For the time being, I changed my copy of DaemonLock.init from

     def __init__(self, file=None, callbackfn=None,
                     desc='daemon lock', debug=False):
    
            self.pidfile = file if file else os.path.join(os.path.dirname(__file__),
                                                          'running.lock')
    
            self.callbackfn = callbackfn
            self.desc = desc
            self.debug = debug
            self.held = False
            #run the lock automatically !
            self.lock()
            self._finalize = Finalize(self, DaemonLock._on_finalize,
                                        args=(self, debug), exitpriority=10)
    

    to

     def __init__(self, file=None, callbackfn=None,
                     desc='daemon lock', debug=False):
    
            self.pidfile = file if file else os.path.join(os.path.dirname(__file__),
                                                          'running.lock')
    
            # only added these two lines to force writing in a writable directory
            if not os.access(self.pidfile, os.W_OK):
                self.pidfile = os.path.join("/var/www/wsgidir", os.path.basename(self.pidfile))
    
            self.callbackfn = callbackfn
            self.desc = desc
            self.debug = debug
            self.held = False
            #run the lock automatically !
            self.lock()
            self._finalize = Finalize(self, DaemonLock._on_finalize,
                                        args=(self, debug), exitpriority=10)
    

    And now I am able to view statistics without receiving a 500 internal error.

  2. Marcin Kuzminski repo owner

    There's patch for this already present, but not merged into sources. It'll be fixed soon.

  3. MarkLIC reporter

    Oops, I should have looked through the existing bugs.

    I'm looking forward to the next release in that case! Thanks.

  4. Log in to comment