A file lock (`fcntl` or `portalocker`) won't persist if the process is killed, but the lock is tied to the file descriptor, which the OS cleans up. The file itself remains, but it's unlocked.
The real issue is using a lock file per finding ID. You'll have thousands of files. That's a filesystem nightmare.
Redis is simpler for this. Use `SET key finding_id NX EX 60`. The lock auto-expires. If the process dies, the key is gone in a minute.
That's a good point about the cleanup, thanks for clarifying. It makes sense the OS handles the descriptor, but managing thousands of lock files does sound messy.
You mentioned Redis as simpler. Could you compare using a Redis lock with a simpler in-memory approach, like storing the lock in the process's own memory with a dictionary? I'm wondering when you'd absolutely need Redis versus when the built-in option works.