2002-10-07 23:17:13 +02:00
|
|
|
# OfflineIMAP synchronization master code
|
2007-07-04 19:53:48 +02:00
|
|
|
# Copyright (C) 2002-2007 John Goerzen
|
2002-10-07 23:17:13 +02:00
|
|
|
# <jgoerzen@complete.org>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
2003-04-16 21:23:45 +02:00
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
2002-10-07 23:17:13 +02:00
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
2006-08-12 06:15:55 +02:00
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2002-10-07 23:17:13 +02:00
|
|
|
|
2011-03-11 22:13:21 +01:00
|
|
|
from offlineimap.threadutil import threadlist, InstanceLimitedThread
|
2011-05-07 17:40:32 +02:00
|
|
|
from offlineimap.accounts import SyncableAccount
|
2010-12-01 16:13:15 +01:00
|
|
|
from threading import currentThread
|
2002-10-07 23:17:13 +02:00
|
|
|
|
2011-05-07 17:40:32 +02:00
|
|
|
def syncaccount(threads, config, accountname):
|
2008-05-20 08:38:32 +02:00
|
|
|
account = SyncableAccount(config, accountname)
|
2003-01-04 05:57:46 +01:00
|
|
|
thread = InstanceLimitedThread(instancename = 'ACCOUNTLIMIT',
|
|
|
|
target = account.syncrunner,
|
2011-05-07 17:40:32 +02:00
|
|
|
name = "Account sync %s" % accountname)
|
2011-10-26 16:47:21 +02:00
|
|
|
thread.setDaemon(True)
|
2003-01-04 05:57:46 +01:00
|
|
|
thread.start()
|
2003-04-29 02:04:22 +02:00
|
|
|
threads.add(thread)
|
2011-01-12 11:15:12 +01:00
|
|
|
|
2011-05-07 17:40:32 +02:00
|
|
|
def syncitall(accounts, config):
|
2011-11-02 11:55:05 +01:00
|
|
|
# Special exit message for SyncRunner thread, so main thread can exit
|
|
|
|
currentThread().exit_message = 'SYNCRUNNER_EXITED_NORMALLY'
|
2010-12-01 16:13:15 +01:00
|
|
|
threads = threadlist()
|
2002-10-07 23:17:13 +02:00
|
|
|
for accountname in accounts:
|
2011-05-07 17:40:32 +02:00
|
|
|
syncaccount(threads, config, accountname)
|
2003-04-29 02:04:22 +02:00
|
|
|
# Wait for the threads to finish.
|
|
|
|
threads.reset()
|