Ticket #9133: lockexception.diff
File lockexception.diff, 1.0 KB (added by , 16 years ago) |
---|
-
django/core/files/locks.py
40 40 except (ImportError, AttributeError): 41 41 pass 42 42 43 class LockException(Exception): 44 # Error codes: 45 LOCK_FAILED = 1 46 43 47 def fd(f): 44 48 """Get a filedescriptor from something which could be a file or an fd.""" 45 49 return hasattr(f, 'fileno') and f.fileno() or f … … 54 58 win32file.UnlockFileEx(hfile, 0, -0x10000, __overlapped) 55 59 elif system_type == 'posix': 56 60 def lock(file, flags): 57 fcntl.lockf(fd(file), flags) 61 try: 62 fcntl.lockf(fd(file), flags) 63 except IOError, exc_value: 64 # IOError: [Errno 11] Resource temporarily unavailable 65 if exc_value[0] == 11: 66 raise LockException(LockException.LOCK_FAILED, exc_value[1]) 67 else: 68 raise 58 69 59 70 def unlock(file): 60 71 fcntl.lockf(fd(file), fcntl.LOCK_UN)