|
Gaudi Framework, version v22r4 |
| Home | Generated: Fri Sep 2 2011 |
Classes | |
| class | LockFile |
| Lock a file. More... | |
Functions | |
| def | lock |
| def | unlock |
| def | _tmpFileName |
| def | _lckFileName |
| def | _linkCount |
| def | _read |
| def | _sleep |
Variables | |
| LOCK_EX = fcntl.F_WRLCK | |
| LOCK_SH = fcntl.F_RDLCK | |
| LOCK_NB = fcntl.F_UNLCK | |
| def locker::_lckFileName | ( | fileName ) | [private] |
| def locker::_linkCount | ( | lockFileName ) | [private] |
| def locker::_read | ( | fileName ) | [private] |
| def locker::_sleep | ( | ) | [private] |
| def locker::_tmpFileName | ( | fileName ) | [private] |
| def locker::lock | ( | file ) |
Lock first 10 bytes of a file.
Definition at line 19 of file locker.py.
00020 : 00021 """ 00022 Lock first 10 bytes of a file. 00023 """ 00024 pos = file.tell() # remember current position 00025 file.seek(0) 00026 # By default, python tries about 10 times, then throws an exception. 00027 # We want to wait forever. 00028 acquired = False 00029 while not acquired: 00030 try: 00031 msvcrt.locking(file.fileno(),msvcrt.LK_LOCK,10) 00032 acquired = True 00033 except IOError, x: 00034 if x.errno != 36: # 36, AKA 'Resource deadlock avoided', is normal 00035 raise 00036 file.seek(pos) # reset position
| def locker::unlock | ( | file ) |
Unlock first 10 bytes of a file.
| locker::LOCK_EX = fcntl.F_WRLCK |
| locker::LOCK_NB = fcntl.F_UNLCK |
| locker::LOCK_SH = fcntl.F_RDLCK |