Remove weird SigListener class
The SigListener class was used to queue folders that we need to sync and to receive "resync" and "abort" signals. It was undocumented and weird and we had to pass "siglisteners" through the whole program. Simply do away with it, and make 2 functions in the Account() class: set_abort_event and get_abort_event which can be used to set and check for such signals. This way we do not need to pass siglisteners all over the place. Tested Blinkenlights and TTYUI uis to make sure that SIGUSR1 and SIGUSR2 actually still work. Document those signals in MANUAL.rst. They were completly undocumented. This simplifies the code and interdependencies by passing less stuff around. Removes an undocumented and weirdly named class. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:

committed by
Nicolas Sebrecht

parent
ac27c93c83
commit
89619838b0
@ -17,26 +17,22 @@
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
from offlineimap.threadutil import threadlist, InstanceLimitedThread
|
||||
from offlineimap.accounts import SyncableAccount, SigListener
|
||||
from offlineimap.accounts import SyncableAccount
|
||||
from threading import currentThread
|
||||
|
||||
def syncaccount(threads, config, accountname, siglisteners):
|
||||
def syncaccount(threads, config, accountname):
|
||||
account = SyncableAccount(config, accountname)
|
||||
siglistener = SigListener()
|
||||
thread = InstanceLimitedThread(instancename = 'ACCOUNTLIMIT',
|
||||
target = account.syncrunner,
|
||||
name = "Account sync %s" % accountname,
|
||||
kwargs = {'siglistener': siglistener} )
|
||||
# the Sync Runner thread is the only one that will mutate siglisteners
|
||||
siglisteners.append(siglistener)
|
||||
name = "Account sync %s" % accountname)
|
||||
thread.setDaemon(1)
|
||||
thread.start()
|
||||
threads.add(thread)
|
||||
|
||||
def syncitall(accounts, config, siglisteners):
|
||||
def syncitall(accounts, config):
|
||||
currentThread().setExitMessage('SYNC_WITH_TIMER_TERMINATE')
|
||||
threads = threadlist()
|
||||
for accountname in accounts:
|
||||
syncaccount(threads, config, accountname, siglisteners)
|
||||
syncaccount(threads, config, accountname)
|
||||
# Wait for the threads to finish.
|
||||
threads.reset()
|
||||
|
Reference in New Issue
Block a user