3 ms·
Python has SQLite. This means you can lock a db file on all platforms and synchronize processes using SQLite.
by knuthsat 5y ago
Python has SQLite. This means you can lock a db file on all platforms and synchronize processes using SQLite.
- justinator 5y agoThat seems a little inefficient to pull in SQLite just so that you can have it lock a file, when you can just lock your own file, don't you think? glances around nervously is flocking one of those "what's old is new again" concept that people are just now relearning? Surely a blog post on how not to have two concurrent cronjobs running is kind of a weird thing to read when some Linux grey beard figured this out in the 90's on their lunch break.
- deleted 5y ago[deleted]
- knuthsat 5y agoSQLite comes for free in Python distribution. The only reason why I mentioned it. Of course, just having a nice cross-platform file locking interface would be nice (not the case for Python).
- justinator 5y agoI meant in a complexity/memory way. Exclusive locks themselves aren't actually cross platform - it would vary on your fs. That's why you don't see a nice cross-platform file locking interface. I'm not sure if you can guarantee an exclusive lock in SQLite on something like a nfs?
- knuthsat 5y agoThis is from SQLite docs: > SQLite uses POSIX advisory locks to implement locking on Unix. On Windows it uses the LockFile(), LockFileEx(), and UnlockFile() system calls. SQLite assumes that these system calls all work as advertised. If that is not the case, then database corruption can result. One should note that POSIX advisory locking is known to be buggy or even unimplemented on many NFS implementations (including recent versions of Mac OS X) and that there are reports of locking problems for network filesystems under Windows. Your best defense is to not use SQLite for files on a network filesystem. I guess cross-platform for naive me is POSIX + Windows.