summaryrefslogtreecommitdiffstats
path: root/kolabd
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-10-28 12:17:41 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-10-28 12:17:41 +0100
commit45d4f21fe57ba47f97bf29e714bacdecdd2edca2 (patch)
treee9d9a2cb0cd670467fbb153610fc26062168d7ca /kolabd
parentc7a72390e2996039da5920981780030e066db960 (diff)
downloadpykolab-45d4f21fe57ba47f97bf29e714bacdecdd2edca2.tar.gz
Use one fork per domain name space found
Diffstat (limited to 'kolabd')
-rw-r--r--kolabd/__init__.py40
1 files changed, 24 insertions, 16 deletions
diff --git a/kolabd/__init__.py b/kolabd/__init__.py
index 3c161e2..56bfe9b 100644
--- a/kolabd/__init__.py
+++ b/kolabd/__init__.py
@@ -100,29 +100,37 @@ class KolabDaemon(object):
sys.exit(exitcode)
def do_sync(self):
+ domain_auth = {}
+
+ pid = os.getpid()
+
while 1:
- imap = IMAP()
- if hasattr(imap,'auth'):
- auth = imap.auth
- else:
- auth = Auth()
+ primary_auth = Auth()
log.debug(_("Listing domains..."), level=5)
+
start = time.time()
- domains = auth.list_domains()
+ domains = primary_auth.list_domains()
+ if len(domains) == len(domain_auth.keys()):
+ time.sleep(600)
end = time.time()
- log.debug(_("Found %d domains in %d seconds") %(len(domains),(end-start)), level=8)
- all_folders = []
+ log.debug(_("Found %d domains in %d seconds") %(len(domains),(end-start)), level=8)
for primary_domain,secondary_domains in domains:
log.debug(_("Running for domain %s") %(primary_domain), level=5)
- auth.connect(primary_domain)
- start_time = time.time()
- auth.synchronize(primary_domain, secondary_domains)
- end_time = time.time()
-
- log.info(_("Synchronizing users for %s took %d seconds")
- %(primary_domain, (end_time-start_time))
- )
+ if not pid == 0 and not domain_auth.has_key(primary_domain):
+ log.debug(_("Domain %s did not have a key yet") %(primary_domain), level=5)
+ domain_auth[primary_domain] = Auth()
+ pid = os.fork()
+ if pid == 0:
+ domain_auth[primary_domain].connect(primary_domain)
+ start_time = time.time()
+ domain_auth[primary_domain].synchronize(primary_domain, secondary_domains)
+ end_time = time.time()
+
+ log.info(_("Synchronizing users for %s took %d seconds")
+ %(primary_domain, (end_time-start_time))
+ )
+ domain_auth[primary_domain].synchronize(primary_domain, secondary_domains)