mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-26 01:50:31 +00:00
Stop e-mail-thread on quit or restart
This commit is contained in:
parent
b0cbd0a37a
commit
7a38c05f12
@ -84,6 +84,7 @@ class email_SSL(email):
|
||||
class EMailThread(threading.Thread):
|
||||
|
||||
def __init__(self):
|
||||
self._stopevent = threading.Event()
|
||||
threading.Thread.__init__(self)
|
||||
self.status = 0
|
||||
self.current = 0
|
||||
@ -93,16 +94,19 @@ class EMailThread(threading.Thread):
|
||||
self.asyncSMTP=None
|
||||
|
||||
def run(self):
|
||||
while 1:
|
||||
while not self._stopevent.isSet():
|
||||
doLock = threading.Lock()
|
||||
doLock.acquire()
|
||||
if self.current != self.last:
|
||||
doLock.release()
|
||||
self.send_raw_email()
|
||||
self.current += 1
|
||||
|
||||
doLock.release()
|
||||
time.sleep(1)
|
||||
|
||||
def stop(self):
|
||||
self._stopevent.set()
|
||||
|
||||
def get_send_status(self):
|
||||
if self.asyncSMTP:
|
||||
return self.asyncSMTP.getTransferStatus()
|
||||
@ -134,7 +138,7 @@ class EMailThread(threading.Thread):
|
||||
# if more than 50 entries in the list, clean the list
|
||||
addLock = threading.Lock()
|
||||
addLock.acquire()
|
||||
if self.last >= 3:
|
||||
if self.last >= 20:
|
||||
self.delete_completed_tasks()
|
||||
# progress, runtime, and status = 0
|
||||
self.queue.append({'data':data, 'settings':settings, 'recipent':recipient, 'starttime': 0,
|
||||
|
@ -70,6 +70,7 @@ class server:
|
||||
|
||||
if self.restart == True:
|
||||
web.app.logger.info("Performing restart of Calibre-web")
|
||||
web.helper.global_eMailThread.stop()
|
||||
if os.name == 'nt':
|
||||
arguments = ["\"" + sys.executable + "\""]
|
||||
for e in sys.argv:
|
||||
@ -79,6 +80,7 @@ class server:
|
||||
os.execl(sys.executable, sys.executable, *sys.argv)
|
||||
else:
|
||||
web.app.logger.info("Performing shutdown of Calibre-web")
|
||||
web.helper.global_eMailThread.stop()
|
||||
sys.exit(0)
|
||||
|
||||
def setRestartTyp(self,starttyp):
|
||||
|
Loading…
Reference in New Issue
Block a user