From 4442a7ce674b80522eb74c4c58318d234adbe9b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= Date: Sun, 30 Aug 2020 14:01:51 +0200 Subject: [PATCH] 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. --- offlineimap/folder/UIDMaps.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/offlineimap/folder/UIDMaps.py b/offlineimap/folder/UIDMaps.py index 51e4970..633fa1c 100644 --- a/offlineimap/folder/UIDMaps.py +++ b/offlineimap/folder/UIDMaps.py @@ -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: