folder/UIDMaps.py import fcntl
First, this file calls fcntl, but it has a typo. Then, I import the fcntl library, as done in offlineimap/accounts.py using portalocker first.
This commit is contained in:
parent
e4cb1a93be
commit
4442a7ce67
@ -22,6 +22,14 @@ from sys import exc_info
|
|||||||
from threading import Lock
|
from threading import Lock
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
try:
|
||||||
|
import portalocker
|
||||||
|
except:
|
||||||
|
try:
|
||||||
|
import fcntl
|
||||||
|
except:
|
||||||
|
pass # Ok if this fails, we can do without.
|
||||||
|
|
||||||
from offlineimap import OfflineImapError
|
from offlineimap import OfflineImapError
|
||||||
from .IMAP import IMAPFolder
|
from .IMAP import IMAPFolder
|
||||||
|
|
||||||
@ -61,7 +69,7 @@ class MappedIMAPFolder(IMAPFolder):
|
|||||||
mapfilenamelock = "%s.lock" % mapfilename
|
mapfilenamelock = "%s.lock" % mapfilename
|
||||||
with self.maplock and open(mapfilenamelock, 'w') as mapfilelock:
|
with self.maplock and open(mapfilenamelock, 'w') as mapfilelock:
|
||||||
try:
|
try:
|
||||||
fnctl.lockf(mapfilelock, fnctl.LOCK_EX) # Blocks until acquired.
|
fcntl.lockf(mapfilelock, fcntl.LOCK_EX) # Blocks until acquired.
|
||||||
except NameError:
|
except NameError:
|
||||||
pass # Windows...
|
pass # Windows...
|
||||||
if os.path.exists(mapfilenametmp):
|
if os.path.exists(mapfilenametmp):
|
||||||
@ -106,7 +114,7 @@ class MappedIMAPFolder(IMAPFolder):
|
|||||||
# different processes. However, we still need to protect for
|
# different processes. However, we still need to protect for
|
||||||
# multiple access from different threads.
|
# multiple access from different threads.
|
||||||
try:
|
try:
|
||||||
fnctl.lockf(mapfilelock, fnctl.LOCK_EX) # Blocks until acquired.
|
fcntl.lockf(mapfilelock, fcntl.LOCK_EX) # Blocks until acquired.
|
||||||
except NameError:
|
except NameError:
|
||||||
pass # Windows...
|
pass # Windows...
|
||||||
with open(mapfilenametmp, 'wt') as mapfilefd:
|
with open(mapfilenametmp, 'wt') as mapfilefd:
|
||||||
|
Loading…
Reference in New Issue
Block a user