Accepting request 244786 from home:mcaj:branches:Base:System
- I wrote a patch got-lock.patch to fix the trouble with the got-lock variable.I was testing the withlock and still had there the lock file after a program already end with exit code 0. I have look on the code together with our Python expert mvidner@suse.cz and we found the got-lock variable isn't marked ad global variable. We have tested it and with the patch the program is working very well. I send this patch also to upstream (poeml@cmdline.net) OBS-URL: https://build.opensuse.org/request/show/244786 OBS-URL: https://build.opensuse.org/package/show/Base:System/withlock?expand=0&rev=8
This commit is contained in:
parent
cd83fb1e7f
commit
fe9d84134b
56
got-lock.patch
Normal file
56
got-lock.patch
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
Index: withlock-0.3/withlock
|
||||||
|
===================================================================
|
||||||
|
--- withlock-0.3.orig/withlock
|
||||||
|
+++ withlock-0.3/withlock
|
||||||
|
@@ -64,12 +64,21 @@ for name in 'SIGBREAK', 'SIGHUP', 'SIGTE
|
||||||
|
if num: signal.signal(num, catchterm)
|
||||||
|
|
||||||
|
|
||||||
|
-def cleanup(lockfile):
|
||||||
|
+def cleanup(lockfile, verbose):
|
||||||
|
+ global got_lock
|
||||||
|
+ if verbose:
|
||||||
|
+ sys.stderr.write('got_lock is set to: %r\n' % got_lock)
|
||||||
|
+
|
||||||
|
+ if verbose:
|
||||||
|
+ sys.stderr.write('removing lockfile: %r\n' % lockfile)
|
||||||
|
+
|
||||||
|
if got_lock:
|
||||||
|
try:
|
||||||
|
os.unlink(lockfile)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
+ else:
|
||||||
|
+ sys.stderr.write('the lockfile was not removed !\n')
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
@@ -132,6 +141,7 @@ def main():
|
||||||
|
|
||||||
|
lock = open(lockfile, 'w')
|
||||||
|
|
||||||
|
+ global got_lock
|
||||||
|
while 1 + 1 == 2:
|
||||||
|
|
||||||
|
try:
|
||||||
|
@@ -174,7 +184,7 @@ def main():
|
||||||
|
% lockfile)
|
||||||
|
|
||||||
|
|
||||||
|
- atexit.register(cleanup, lockfile)
|
||||||
|
+ atexit.register(cleanup, lockfile, options.verbose)
|
||||||
|
os.umask(prev_umask)
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
@@ -184,10 +194,7 @@ def main():
|
||||||
|
|
||||||
|
if options.verbose:
|
||||||
|
sys.stderr.write('command terminated with exit code %s\n' % rc)
|
||||||
|
-
|
||||||
|
- if options.verbose:
|
||||||
|
- sys.stderr.write('removing lockfile\n')
|
||||||
|
-
|
||||||
|
+
|
||||||
|
sys.exit(rc)
|
||||||
|
|
||||||
|
|
@ -1,3 +1,13 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Aug 14 13:23:11 UTC 2014 - mcaj@suse.com
|
||||||
|
|
||||||
|
- I wrote a patch got-lock.patch to fix the trouble with the got-lock variable.
|
||||||
|
I was testing the withlock and still had there the lock file after a
|
||||||
|
program already end with exit code 0. I have look on the code together
|
||||||
|
with our Python expert mvidner@suse.cz and we found the got-lock variable
|
||||||
|
isn't marked ad global variable.I`ll send this to poeml@cmdline.net
|
||||||
|
after we test it on our servers.
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue Mar 25 21:07:09 UTC 2014 - poeml@cmdline.net
|
Tue Mar 25 21:07:09 UTC 2014 - poeml@cmdline.net
|
||||||
|
|
||||||
|
@ -26,6 +26,8 @@ Url: http://code.google.com/p/withlock/
|
|||||||
Requires: python
|
Requires: python
|
||||||
Source0: http://mirrorbrain.org/files/releases/%{name}-%{version}.tar.gz
|
Source0: http://mirrorbrain.org/files/releases/%{name}-%{version}.tar.gz
|
||||||
Source1: %name-README.SuSE
|
Source1: %name-README.SuSE
|
||||||
|
# fixed trouble with not removed lock file bacuse got-lock was not global variable.
|
||||||
|
Patch0: got-lock.patch
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
@ -40,7 +42,9 @@ to use, and much better than implementing half-hearted locking within scripts.
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup
|
%setup
|
||||||
#
|
|
||||||
|
%patch0 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
#
|
#
|
||||||
%install
|
%install
|
||||||
|
Loading…
x
Reference in New Issue
Block a user