Download:
child 84:75dafcb54f2c
parent 82:5a8a919160a5
83:ad889ea48249
Anton Shestakov <av6@dwimlabs.net>, Sun, 07 Aug 2016 13:03:34 +0800
bench: unlock at (any kind of) exit Helps with running bench.py via a wrapper shell script, for example.

1 файлов изменено, 11 вставок(+), 10 удалений(-) [+]
bench.py file | annotate | diff | comparison | revisions
--- a/bench.py Sun Aug 07 12:59:40 2016 +0800
+++ b/bench.py Sun Aug 07 13:03:34 2016 +0800
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+import atexit
import errno
import logging
import os
@@ -295,17 +296,17 @@
else:
names = args.marks.split(',')
marks = OrderedDict((k, v) for k, v in MARKS.items() if k in names)
+
lockfd = lock(LOCKFILE)
- try:
- dbinit()
- if args.auto:
- if args.retry:
- args.revsets = guessspikes(args.auto, marks)
- else:
- args.revsets = guessnew(args.auto, marks)
- dbupdate(args.revsets, marks, args.mintime, args.mintries, args.retry)
- finally:
- unlock(lockfd, LOCKFILE)
+ atexit.register(unlock, lockfd, LOCKFILE)
+
+ dbinit()
+ if args.auto:
+ if args.retry:
+ args.revsets = guessspikes(args.auto, marks)
+ else:
+ args.revsets = guessnew(args.auto, marks)
+ dbupdate(args.revsets, marks, args.mintime, args.mintries, args.retry)
if __name__ == '__main__':