I needed a quick locking mechanism to prevent my daemons from stepping over each other. To have a sane daemon startup (and prevent multiple daemon spawns), we need to ensure that we have an exclusive lock before starting the program. Googling around didn't lead to show any context managers that actually use the flock syscalls.
So here goes my attempt that seems to work:
Spinning off some python processes that utilise this context manager shows serialisation taking place:
And here's the output of lsof showing locking for the processes spun off above:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment