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:
Rodolfo García Peñas (kix) 2020-08-30 14:01:51 +02:00
parent e4cb1a93be
commit 4442a7ce67

View File

@ -22,6 +22,14 @@ from sys import exc_info
from threading import Lock
import six
try:
import portalocker
except:
try:
import fcntl
except:
pass # Ok if this fails, we can do without.
from offlineimap import OfflineImapError
from .IMAP import IMAPFolder
@ -61,7 +69,7 @@ class MappedIMAPFolder(IMAPFolder):
mapfilenamelock = "%s.lock" % mapfilename
with self.maplock and open(mapfilenamelock, 'w') as mapfilelock:
try:
fnctl.lockf(mapfilelock, fnctl.LOCK_EX) # Blocks until acquired.
fcntl.lockf(mapfilelock, fcntl.LOCK_EX) # Blocks until acquired.
except NameError:
pass # Windows...
if os.path.exists(mapfilenametmp):
@ -106,7 +114,7 @@ class MappedIMAPFolder(IMAPFolder):
# different processes. However, we still need to protect for
# multiple access from different threads.
try:
fnctl.lockf(mapfilelock, fnctl.LOCK_EX) # Blocks until acquired.
fcntl.lockf(mapfilelock, fcntl.LOCK_EX) # Blocks until acquired.
except NameError:
pass # Windows...
with open(mapfilenametmp, 'wt') as mapfilefd: