> Here's my guess. OP is trying to implement locking in Python. OP sees that > SQLite does locking and wants to copy code. > > Obviously, that's beyond the range of this mailing list, but just to be > helpful, here's some stackoverflow: > > <https://stackoverflow.com/questions/489861/locking-a-file-in-python#498505>
I don't think this implementation in Python is the same as that in SQLite3. By default, it uses either a link or a directory to lock a file. https://github.com/pypa/pip/blob/master/src/pip/_vendor/lockfile/__init__.py#L340 if hasattr(os, "link"): from . import linklockfile as _llf LockFile = _llf.LinkLockFile else: from . import mkdirlockfile as _mlf LockFile = _mlf.MkdirLockFile FileLock = LockFile There is something shown below that uses SQLite3, but it still does not go deeper into reimplementing using the raw code available from SQLite3. This implementation merely calls SQLite3. https://github.com/pypa/pip/blob/master/src/pip/_vendor/lockfile/sqlitelockfile.py#L14 My take-home message from this code is that it might be difficult to just extract the part from SQLite3 that is for file locking. Otherwise, the author who wrote this piece of code probably should have done so already. However, for more efficient file locking, I think it probably makes sense to only extract the part for file locking SQLite3 and remove other parts SQLite3 to reduce overhead. -- Regards, Peng _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users