Commit 0db22fd615f995b710fb68d4c7492d407ffb60de
- Date: Mon May 05 16:54:35 +0000 2008
- Committer: Will Fisher (will@gina.alaska.edu)
- Author: Will Fisher (will@gina.alaska.edu)
- Commit SHA1: 0db22fd615f995b710fb68d4c7492d407ffb60de
- Tree SHA1: 1baee68163bbf700879ddf990c6f5c6851f56024
Ensure that the lock file cleans it's self up except when we encounter a TaskLockError
Commit diff
| |   |
| 24 | 24 | end |
| 25 | 25 | FileUtils.touch(LOCK_FILE_PATH) |
| 26 | 26 | yield |
| 27 | | FileUtils.rm(LOCK_FILE_PATH) |
| 28 | 27 | rescue TaskLockError |
| 29 | 28 | $stderr.puts "Task lockfile exists" |
| 30 | 29 | exit(1) |
| 30 | ensure |
| 31 | FileUtils.rm(LOCK_FILE_PATH) |
| 31 | 32 | end |
| 32 | 33 | end |
| 33 | 34 | |
| … | … | |
| 45 | 45 | $stderr.puts exception_backtrace_string |
| 46 | 46 | exit(1) |
| 47 | 47 | end |
| 48 | | end |
| 48 | end |
| toggle raw diff |
--- a/script/task_performer
+++ b/script/task_performer
@@ -24,10 +24,11 @@ def with_lock(&block)
end
FileUtils.touch(LOCK_FILE_PATH)
yield
- FileUtils.rm(LOCK_FILE_PATH)
rescue TaskLockError
$stderr.puts "Task lockfile exists"
exit(1)
+ ensure
+ FileUtils.rm(LOCK_FILE_PATH)
end
end
@@ -44,4 +45,4 @@ with_lock do
$stderr.puts exception_backtrace_string
exit(1)
end
-end
\ No newline at end of file
+end |