Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work on Ubuntu 14.04, python 2.7.6? #11

Closed
vladiibine opened this issue Jan 6, 2016 · 1 comment
Closed

Doesn't work on Ubuntu 14.04, python 2.7.6? #11

vladiibine opened this issue Jan 6, 2016 · 1 comment

Comments

@vladiibine
Copy link

So I did this in one python console (the file already existed)

import portalocker as pl
f1 = open('./asdf', 'w')
pl.lock(f1, pl.LOCK_EX)

Then in another python console I did this

f1 = open('./asdf', 'w')
f1.write('zzzzzzzzzzzzzzzzfdffffffffffffffffffffffffff')
f1.close()

Then I do this in a bash console

$ cat ./asdf
zzzzzzzzzzzzzzzzfdffffffffffffffffffffffffff

Am I missing something about how this is supposed to work, or does it just not lock the file?

@wolph
Copy link
Owner

wolph commented Jan 6, 2016

It does actually lock the file but on Ubuntu the code uses flock() internally, these locks are advisory which means there is no actual requirement to follow the locking.

Just execute the code from your console in 2 separate consoles and you will notice the locks but as far as I know there is no standard way to force locking on Ubuntu without changing your mounts to mandatory locking (with -o mand). But even these are known to be buggy unfortunately.

@wolph wolph closed this as completed Apr 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants