OSerror when downloading files via NFS

When I try to download a media file through the django admin interface, I get this error:

OSError: [Errno 45] Operation not supported 

Here is the last trace line:

  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 this commit , entered on the ticket as a "workaround" (see below).

Here is the change I have to make in django/core/files/locks.py according to a 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 manually undoing the changes from this commit (replacing flock() calls with lockf() calls, but I still get the same error. There are also patches there, but these patches seem old (~ 7 years old and I am using django 1.9 with python 3.5).

How can i solve this?

EDIT:

As mentioned in plombix, my home directory is installed on NFS.

EDIT2:

I also tried replacing flock calls with fcntl.fcntl() calls, and I got another error:

 OSError: [Errno 14] Bad address 
+5
source share
1 answer

You can indicate that you are on the NFS file system, P

lockf == flock UNSUPORTED by NFS

cf another post on the stack flock vs lockf "

If the semantics (behavior over descriptor passing, markup, etc.) are acceptable, you should prefer lockf () / fcntl () to block flock ().

Locks in Linux, simply because the former works with NFS and other file systems, while the latter does not.

On BSD and Mac OS X, I believe you need to use fcntl () explicitly.

I suggest you redirect your operations to / temp or / goinfre /

+1
source

Source: https://habr.com/ru/post/1245552/


All Articles