create directories under .cache in thread-safe way
new utils.lock module for creating locks while handling stale locks
use new lock context manager to acquire locks while cleaning up stale ones
break lock immediately if it is too old and use warning when breaking it
Merge pull request #379 from ndawe/lock

MRG: Acquire locks while cleaning up stale ones