Shared file locks don't work between processes
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
tooz |
New
|
Undecided
|
Unassigned |
Bug Description
Currently only the FileLock driver implements shared locks, but contrary to what one would expect, they only work within the same process and don't work between processes.
This is easy to confirm. Besides reading the code, we can just run the following code:
import multiprocessing
import os
import time
from tooz import coordination
def test(i):
cwd = os.getcwd()
me = str(os.getpid())
print(
coordinator = coordination.
coordinat
try:
lock = coordinator.
with lock (blocking=True, shared=True):
finally:
with multiprocessing
p.map(test, range(2))
And we'll see that shared locks between processes are behaving like exclusive locks:
Starting coordinator for process 14772
Starting coordinator for process 14773
Shared lock acquired by 14772, proceeding to sleep
Shared lock released by 14772
Stopped coordinator for process 14772
Shared lock acquired by 14773, proceeding to sleep
Shared lock released by 14773
Stopped coordinator for process 14773
[None, None]