Re: system wide mutex

2014-02-10 Thread Miki Tebeka
IIRC creating a directory is atomic in most environments. On Sunday, February 9, 2014 2:39:51 AM UTC-8, Asaf Las wrote: > Hi > > > > Which one is most recommended to use for mutex alike locking to > > achieve atomic access to single resource: > > > > - fcntl.lockf > > - os.open() with O_

Re: system wide mutex

2014-02-10 Thread Grant Edwards
On 2014-02-09, Asaf Las wrote: > Hi > > Which one is most recommended to use for mutex alike locking to > achieve atomic access to single resource: > > - fcntl.lockf > - os.open() with O_SHLOCK and O_EXLOCK > - https://pypi.python.org/pypi/lockfile/0.9.1 > - https://pypi.python.org/pypi/zc.lock

Re: system wide mutex

2014-02-09 Thread Chris Angelico
On Mon, Feb 10, 2014 at 1:45 AM, Roy Smith wrote: > In article , > Skip Montanaro wrote: > >> As the author of lockfile, I can tell you it only implements advisory >> locking. All programs needing to access the locked resources must >> cooperate. > > This is true of all mutexes, no? > Not quite

Re: system wide mutex

2014-02-09 Thread Asaf Las
Hi Thanks for replies. It would be good to have blocking implementation. I have to check fcntl if it works in blocking mdoe on CentOS. Meanwhile there is Posix Semaphore made for Python: http://semanchuk.com/philip/posix_ipc/ will try it as well. /Asaf -- https://mail.python.org/mailman/li

Re: system wide mutex

2014-02-09 Thread Marko Rauhamaa
Asaf Las : > Which one is most recommended to use for mutex alike locking to > achieve atomic access to single resource: > > - fcntl.lockf I recommend fcntl.flock: #!/usr/bin/python3 import sys, fcntl, time with open("te

Re: system wide mutex

2014-02-09 Thread Skip Montanaro
On Sun, Feb 9, 2014 at 8:45 AM, Roy Smith wrote: > This is true of all mutexes, no? Hmmm... You might well be right. I thought that use of the O_EXLOCK flag in the open(2) system call would prevent other processes from opening the file, but (at least on my Mac) it just blocks until the first proc

Re: system wide mutex

2014-02-09 Thread Roy Smith
In article , Skip Montanaro wrote: > > Which one is most recommended to use for mutex alike locking to > > achieve atomic access to single resource: > > > > - fcntl.lockf > > - os.open() with O_SHLOCK and O_EXLOCK > > - https://pypi.python.org/pypi/lockfile/0.9.1 > > - https://pypi.python.org/py

Re: system wide mutex

2014-02-09 Thread Asaf Las
On Sunday, February 9, 2014 1:00:39 PM UTC+2, Skip Montanaro wrote: > > Which one is most recommended to use for mutex alike locking to > > achieve atomic access to single resource: > > > > - fcntl.lockf > > - os.open() with O_SHLOCK and O_EXLOCK > > - https://pypi.python.org/pypi/lockfile/0.9.1 >

Re: system wide mutex

2014-02-09 Thread Asaf Las
Forget to mentioned - CentOS 6.5 Python v3.3. -- https://mail.python.org/mailman/listinfo/python-list

Re: system wide mutex

2014-02-09 Thread Skip Montanaro
> Which one is most recommended to use for mutex alike locking to > achieve atomic access to single resource: > > - fcntl.lockf > - os.open() with O_SHLOCK and O_EXLOCK > - https://pypi.python.org/pypi/lockfile/0.9.1 > - https://pypi.python.org/pypi/zc.lockfile/1.1.0 > - any other ? As the author

system wide mutex

2014-02-09 Thread Asaf Las
Hi Which one is most recommended to use for mutex alike locking to achieve atomic access to single resource: - fcntl.lockf - os.open() with O_SHLOCK and O_EXLOCK - https://pypi.python.org/pypi/lockfile/0.9.1 - https://pypi.python.org/pypi/zc.lockfile/1.1.0 - any other ? Thanks /Asaf -- htt