Code

Ticket #9433: not_supported_locks.diff

File not_supported_locks.diff, 893 bytes (added by rndblnch, 5 years ago)

better patch (adhere to <http://docs.djangoproject.com/en/dev/internals/contributing/> formatting policy)

Line 
1Index: django/core/files/locks.py
2===================================================================
3--- django/core/files/locks.py  (revision 9333)
4+++ django/core/files/locks.py  (working copy)
5@@ -53,11 +53,20 @@
6         hfile = win32file._get_osfhandle(fd(file))
7         win32file.UnlockFileEx(hfile, 0, -0x10000, __overlapped)
8 elif system_type == 'posix':
9+    def lockf(fd, operation):
10+        try:
11+            fcntl.lockf(fd, operation)
12+        except IOError, e:
13+            if e.errno == 45: # Operation not supported
14+                pass
15+            else:
16+                raise
17+
18     def lock(file, flags):
19-        fcntl.lockf(fd(file), flags)
20+        lockf(fd(file), flags)
21 
22     def unlock(file):
23-        fcntl.lockf(fd(file), fcntl.LOCK_UN)
24+        lockf(fd(file), fcntl.LOCK_UN)
25 else:
26     # File locking is not supported.
27     LOCK_EX = LOCK_SH = LOCK_NB = None