kata198 / namedatomiclock Goto Github PK
View Code? Open in Web Editor NEWPython module for an atomic named lock which is local to the machine.
License: GNU Lesser General Public License v3.0
Python module for an atomic named lock which is local to the machine.
License: GNU Lesser General Public License v3.0
While running a load test, in a multithread application, I've experienced the following error:
Traceback (most recent call last):
File ".../NamedAtomicLock/__init__.py", line 109, in acquire
os.mkdir(self.lockPath)
^^^^^^^^^^^^^^^^^^^^^^^
FileExistsError: [Errno 17] File exists: '/tmp/named_lock'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".../NamedAtomicLock/__init__.py", line 115, in acquire
if os.path.exists(self.lockPath) and os.stat(self.lockPath).st_mtime < time.time() - self.maxLockAge:
^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/named_lock'
For what I understand, the mkdir failed because another process was locking it, the os.path.exists succeeded, then the other process deleted the file, and then the so.stat failed because the te file being absent.
I think it would be better to do the os.stat inside another try and in case of FileNotFoundError, don't try to delete.
In the beginning of acquire function, an If self.held is true we are returning True which could introduce edge cases where for more than one process we will return True before we release the lock.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.