IMAP IDLE cleanup(3): Rename self.event to self.stop_sig
Variable name 'event' is as bad as it gets. Rename it to something that actually describes what it is about. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
0bebd65ba0
commit
6ad0de08ef
@ -461,7 +461,7 @@ class IdleThread(object):
|
|||||||
mode and synchronize once we have a new message"""
|
mode and synchronize once we have a new message"""
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.folder = folder
|
self.folder = folder
|
||||||
self.event = Event()
|
self.stop_sig = Event()
|
||||||
self.ui = getglobalui()
|
self.ui = getglobalui()
|
||||||
if folder is None:
|
if folder is None:
|
||||||
self.thread = Thread(target=self.noop)
|
self.thread = Thread(target=self.noop)
|
||||||
@ -473,7 +473,7 @@ class IdleThread(object):
|
|||||||
self.thread.start()
|
self.thread.start()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.event.set()
|
self.stop_sig.set()
|
||||||
|
|
||||||
def join(self):
|
def join(self):
|
||||||
self.thread.join()
|
self.thread.join()
|
||||||
@ -481,7 +481,7 @@ class IdleThread(object):
|
|||||||
def noop(self):
|
def noop(self):
|
||||||
imapobj = self.parent.acquireconnection()
|
imapobj = self.parent.acquireconnection()
|
||||||
imapobj.noop()
|
imapobj.noop()
|
||||||
self.event.wait()
|
self.stop_sig.wait()
|
||||||
self.parent.releaseconnection(imapobj)
|
self.parent.releaseconnection(imapobj)
|
||||||
|
|
||||||
def dosync(self):
|
def dosync(self):
|
||||||
@ -506,16 +506,16 @@ class IdleThread(object):
|
|||||||
minutes kicks in."""
|
minutes kicks in."""
|
||||||
result, cb_arg, exc_data = args
|
result, cb_arg, exc_data = args
|
||||||
if exc_data is None:
|
if exc_data is None:
|
||||||
if not self.event.isSet():
|
if not self.stop_sig.isSet():
|
||||||
self.needsync = True
|
self.needsync = True
|
||||||
self.event.set()
|
self.stop_sig.set()
|
||||||
else:
|
else:
|
||||||
# We got an "abort" signal.
|
# We got an "abort" signal.
|
||||||
self.imapaborted = True
|
self.imapaborted = True
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
if self.event.isSet():
|
if self.stop_sig.isSet():
|
||||||
return
|
return
|
||||||
self.needsync = False
|
self.needsync = False
|
||||||
self.imapaborted = False
|
self.imapaborted = False
|
||||||
@ -540,8 +540,8 @@ class IdleThread(object):
|
|||||||
self.ui.warn("IMAP IDLE not supported on server '%s'."
|
self.ui.warn("IMAP IDLE not supported on server '%s'."
|
||||||
"Sleep until next refresh cycle." % imapobj.identifier)
|
"Sleep until next refresh cycle." % imapobj.identifier)
|
||||||
imapobj.noop()
|
imapobj.noop()
|
||||||
self.event.wait()
|
self.stop_sig.wait() # self.stop() or IDLE callback are invoked
|
||||||
if self.event.isSet():
|
if self.stop_sig.isSet():
|
||||||
# Can't NOOP on a bad connection.
|
# Can't NOOP on a bad connection.
|
||||||
if not self.imapaborted:
|
if not self.imapaborted:
|
||||||
imapobj.noop()
|
imapobj.noop()
|
||||||
@ -551,5 +551,5 @@ class IdleThread(object):
|
|||||||
if self.needsync:
|
if self.needsync:
|
||||||
# here not via self.stop, but because IDLE responded. Do
|
# here not via self.stop, but because IDLE responded. Do
|
||||||
# another round and invoke actual syncing.
|
# another round and invoke actual syncing.
|
||||||
self.event.clear()
|
self.stop_sig.clear()
|
||||||
self.dosync()
|
self.dosync()
|
||||||
|
Loading…
Reference in New Issue
Block a user