lockfile: ask for forgiveness, not permission
authorChris Larson <chris_larson@mentor.com>
Tue, 8 Mar 2011 16:33:40 +0000 (09:33 -0700)
committerChris Larson <chris_larson@mentor.com>
Tue, 8 Mar 2011 16:38:24 +0000 (09:38 -0700)
commit238151441c74db53d6e4d4753f4f96c32f6f13b6
tree4807dc3b5f87a2e8b9b8b6b30f1790e802356038
parent43dddb2f9689d523588146df3eb86e11f554a8c0
lockfile: ask for forgiveness, not permission

Create the lockfile directory if it doesn't exist, rather than erroring out if
it doesn't exist (was also racy).

Also improve the wording of the error message shown when the lockfile's
directory is not writable.

Note for the future, this function should be improved, particularly with
regard to its exception handling. It should be catching the *exact*
exception(s) it will encounter when the file is locked, and continuing in that
case only. If it did that, there'd be no need for the proactive directory
writability check, as bb.utils.lockfile() would raise an appropriate IOError
for that case.

Signed-off-by: Chris Larson <chris_larson@mentor.com>
lib/bb/utils.py