Mercurial > kallithea
comparison rhodecode/lib/pidlock.py @ 2568:29e999f26998 beta
pidlock always create dirs for lock file
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 07 Jul 2012 13:43:16 +0200 |
parents | d6cb805c92fd |
children | ffd45b185016 |
comparison
equal
deleted
inserted
replaced
2567:5fe0f744bec0 | 2568:29e999f26998 |
---|---|
5 | 5 |
6 from warnings import warn | 6 from warnings import warn |
7 from multiprocessing.util import Finalize | 7 from multiprocessing.util import Finalize |
8 | 8 |
9 from rhodecode.lib.compat import kill | 9 from rhodecode.lib.compat import kill |
10 | |
10 | 11 |
11 class LockHeld(Exception): | 12 class LockHeld(Exception): |
12 pass | 13 pass |
13 | 14 |
14 | 15 |
121 :param lockname: acctual pid of file | 122 :param lockname: acctual pid of file |
122 :param pidfile: the file to write the pid in | 123 :param pidfile: the file to write the pid in |
123 """ | 124 """ |
124 if self.debug: | 125 if self.debug: |
125 print 'creating a file %s and pid: %s' % (pidfile, lockname) | 126 print 'creating a file %s and pid: %s' % (pidfile, lockname) |
127 | |
128 dir_, file_ = os.path.split(pidfile) | |
129 if not os.path.isdir(dir_): | |
130 os.makedirs(dir_) | |
126 pidfile = open(self.pidfile, "wb") | 131 pidfile = open(self.pidfile, "wb") |
127 pidfile.write(lockname) | 132 pidfile.write(lockname) |
128 pidfile.close | 133 pidfile.close |
129 self.held = True | 134 self.held = True |