locklib is a Python libraray that provides some convenient lock classes (like a FileLock or a RecursiveLock wrapper) and Java like synchronization methods.
$ hg clone http://bitbucket.org/panzi/locklib/
$ hg clone ssh://hg@bitbucket.org/panzi/locklib/