mirror of
https://github.com/internetarchive/warcprox.git
synced 2025-01-18 13:22:09 +01:00
Swap fcntl.flock with fcntl.lockf
On Linux, `fcntl.flock` is implemented with `flock(2)`, and `fcntl.lockf` is implemented with `fcntl(2)` — they are not compatible. Java `lock()` appears to be `fcntl(2)`. So, other Java programs working with these files work correctly only with `fcntl.lockf`. `warcprox` MUST use `fcntl.lockf`
This commit is contained in:
parent
eda3da1db7
commit
25c0accc3c
@ -24,7 +24,7 @@ def lock_file(queue, filename):
|
||||
"""
|
||||
try:
|
||||
fi = open(filename, 'ab')
|
||||
fcntl.flock(fi, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
fcntl.lockf(fi, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
fi.close()
|
||||
queue.put('1')
|
||||
except IOError:
|
||||
|
@ -74,7 +74,7 @@ class WarcWriter:
|
||||
self.logger.info('closing %s', self._f_finalname)
|
||||
if self._f_open_suffix == '':
|
||||
try:
|
||||
fcntl.flock(self._f, fcntl.LOCK_UN)
|
||||
fcntl.lockf(self._f, fcntl.LOCK_UN)
|
||||
except IOError as exc:
|
||||
self.logger.error('could not unlock file %s (%s)',
|
||||
self._fpath, exc)
|
||||
@ -106,7 +106,7 @@ class WarcWriter:
|
||||
# file lock.
|
||||
if self._f_open_suffix == '':
|
||||
try:
|
||||
fcntl.flock(self._f, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
fcntl.lockf(self._f, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
except IOError as exc:
|
||||
self.logger.error('could not lock file %s (%s)',
|
||||
self._fpath, exc)
|
||||
|
Loading…
x
Reference in New Issue
Block a user