Permalink
Browse files

Disable old global lock system

Remove the old global locking system. We lock only the accounts that we
currently sync, so you can invoke OfflineImap multiple times now as long
as you sync different accounts. This system is compatible with all
releases >= 6.4.0, so don't run older releases simultanous to this one.

This mostly reverts commit 0d95651,
disabling the old global lock system that we had in parallel to the new one.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
  • Loading branch information...
spaetz committed Jan 6, 2012
1 parent 5509691 commit 1b85e3525678e6038614e0510c0be7f7bc179f88
Showing with 6 additions and 17 deletions.
  1. +6 −0 Changelog.draft.rst
  2. +0 −1 offlineimap/accounts.py
  3. +0 −16 offlineimap/init.py
@@ -13,6 +13,12 @@ others.
New Features
------------

* Remove the old global locking system. We lock only the accounts that
we currently sync, so you can invoke OfflineImap multiple times now as
long as you sync different accounts. This system is compatible with
all releases >= 6.4.0, so don't run older releases simultanous to this
one.

Changes
-------

@@ -191,7 +191,6 @@ def __init__(self, *args, **kwargs):

def lock(self):
"""Lock the account, throwing an exception if it is locked already"""
# Take a new-style per-account lock
self._lockfd = open(self._lockfilepath, 'w')
try:
fcntl.lockf(self._lockfd, fcntl.LOCK_EX|fcntl.LOCK_NB)
@@ -23,10 +23,6 @@
import socket
import logging
from optparse import OptionParser
try:
import fcntl
except ImportError:
pass #it's OK
import offlineimap
from offlineimap import accounts, threadutil, syncmaster
from offlineimap.error import OfflineImapError
@@ -340,18 +336,6 @@ def sig_handler(sig, frame):
#various initializations that need to be performed:
offlineimap.mbnames.init(self.config, syncaccounts)

#TODO: keep legacy lock for a few versions, then remove.
self._legacy_lock = open(self.config.getmetadatadir() + "/lock",
'w')
try:
fcntl.lockf(self._legacy_lock, fcntl.LOCK_EX|fcntl.LOCK_NB)
except NameError:
#fcntl not available (Windows), disable file locking... :(
pass
except IOError:
raise OfflineImapError("Could not take global lock.",
OfflineImapError.ERROR.REPO)

if options.singlethreading:
#singlethreaded
self.sync_singlethreaded(syncaccounts)

0 comments on commit 1b85e35

Please sign in to comment.