【发布时间】:2016-07-09 08:07:34
【问题描述】:
当我尝试通过 django 管理界面上传媒体文件时,我收到此错误:
OSError: [Errno 45] Operation not supported
这是回溯的最后一行:
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)
我找到了this answer,其中一位 cmets 将我带到了this ticket,然后又找到了this commit,作为“解决方法”在票证中介绍(见下文)。
根据解决方法,这是我应该在 django/core/files/locks.py 中进行的更改。
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)
我尝试手动撤消此提交的更改(将 flock() 调用替换为 lockf() 调用),但我仍然遇到相同的错误。
也有补丁,但这些补丁似乎很旧(大约 7 岁,我使用 django 1.9 和 python 3.5)。
我该如何解决这个问题?
编辑:
正如 plombix 提到的,我的主目录安装在 NFS 上。
EDIT2:
我还尝试用fcntl.fcntl() 调用替换群调用,但我得到了一个不同的错误:
OSError: [Errno 14] Bad address
【问题讨论】:
-
dokterbob 的分支has this commit,来自有关问题的 cmets,这只是允许传递锁定实现。现在你需要找到一个适用于 AFP 支架的。
标签: django macos python-3.x nfs