Revert "Use lockfile module instead of own code."

This reverts commit aae9e0dce7b4a834a98a259d9f47aa239b48a0aa.

The lockfile module is per thread/process locking, while we need intra
process locking actually.