When I try to upload a media file through the django admin interface, I get this error :
OSError: [Errno 45] Operation not supported
Here is the last line of the traceback :
File "/path/to/home/Envs/myenv/lib/python3.5/site-packages/django/core/files/locks.py", line 112, in unlock
ret = fcntl.lockf(_fd(f), fcntl.LOCK_UN)
I found this answer and one of the comments led me to this ticket and then to this commit, introduced in the ticket as a "workaround" (see below).
Here are the change I should do in django/core/files/locks.py
according to the workaround.
elif system_type == 'posix':
def lock(file, flags):
- fcntl.flock(fd(file), flags)
+ fcntl.lockf(fd(file), flags)
def unlock(file):
- fcntl.flock(fd(file), fcntl.LOCK_UN)
+ fcntl.lockf(fd(file), fcntl.LOCK_UN)
I tried to manually reverse the changes from this commit (replacing flock()
calls with lockf()
calls), but it I still get the same error.
There also are patches, but these patches seem to old (~7 years old and I use django 1.9 with python 3.5).
How could I solve this?
EDIT :
As plombix mentioned, my home directory is mounted on a NFS.
EDIT2 :
I also tried to replace the flock calls with fcntl.fcntl()
calls and I got a different error :
OSError: [Errno 14] Bad address
You may want to specify that you are on a NFS file system ;P
lockf == flock UNSUPORTED by NFS
cf other post in stack "flock vs lockf"
If the semantics (behaviour over descriptor passing, forking, etc.) is acceptable, you should prefer lockf()/fcntl() locks over flock().
Locks in Linux, simply because the former works on NFS etc. filesystems, whereas the latter does not.
On BSDs and Mac OS X, I believe you need to explicitly use fcntl(), instead.
i suggest you redirect your operations over /temp or /goinfre/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With