Skip to content
Permalink
Browse files

use portable locker to support cygwin in Windows

  • Loading branch information...
kimim committed Apr 1, 2019
1 parent 5c735fd commit 94ce99ac9c0b4c5653fe46339feb525571d734a5
Showing with 3 additions and 2 deletions.
  1. +3 −2 offlineimap/accounts.py
@@ -34,7 +34,7 @@
SYNC_MUTEXES_LOCK = Lock()

try:
import fcntl
import portalocker
except:
pass # Ok if this fails, we can do without.

@@ -232,7 +232,7 @@ def __lock(self):

self._lockfd = open(self._lockfilepath, 'w')
try:
fcntl.lockf(self._lockfd, fcntl.LOCK_EX|fcntl.LOCK_NB)
portalocker.lock(self._lockfd, portalocker.LOCK_EX)
except NameError:
#fcntl not available (Windows), disable file locking... :(
pass
@@ -250,6 +250,7 @@ def _unlock(self):

#If we own the lock file, delete it
if self._lockfd and not self._lockfd.closed:
portalocker.unlock(self._lockfd)
self._lockfd.close()
try:
os.unlink(self._lockfilepath)

0 comments on commit 94ce99a

Please sign in to comment.
You can’t perform that action at this time.