Fix for task wrap around

This commit is contained in:
OzzieIsaacs 2020-06-28 13:44:21 +02:00
parent ba10657829
commit 601464083b

View File

@ -206,12 +206,12 @@ class WorkerThread(threading.Thread):
self.doLock.acquire() self.doLock.acquire()
if self.current != self.last: if self.current != self.last:
index = self.current index = self.current
log.info(index)
log.info(len(self.queue))
self.doLock.release() self.doLock.release()
if self.queue[index]['taskType'] == TASK_EMAIL: if self.queue[index]['taskType'] == TASK_EMAIL:
self._send_raw_email() self._send_raw_email()
if self.queue[index]['taskType'] == TASK_CONVERT: elif self.queue[index]['taskType'] in (TASK_CONVERT, TASK_CONVERT_ANY):
self._convert_any_format()
if self.queue[index]['taskType'] == TASK_CONVERT_ANY:
self._convert_any_format() self._convert_any_format()
# TASK_UPLOAD is handled implicitly # TASK_UPLOAD is handled implicitly
self.doLock.acquire() self.doLock.acquire()
@ -274,7 +274,8 @@ class WorkerThread(threading.Thread):
self.add_email(self.queue[index]['settings']['subject'], self.queue[index]['path'], self.add_email(self.queue[index]['settings']['subject'], self.queue[index]['path'],
filename, self.queue[index]['settings'], self.queue[index]['kindle'], filename, self.queue[index]['settings'], self.queue[index]['kindle'],
self.UIqueue[index]['user'], self.queue[index]['title'], self.UIqueue[index]['user'], self.queue[index]['title'],
self.queue[index]['settings']['body']) self.queue[index]['settings']['body'], internal=True)
def _convert_ebook_format(self): def _convert_ebook_format(self):
error_message = None error_message = None
@ -449,11 +450,13 @@ class WorkerThread(threading.Thread):
self.doLock.release() self.doLock.release()
def add_email(self, subject, filepath, attachment, settings, recipient, user_name, taskMessage, def add_email(self, subject, filepath, attachment, settings, recipient, user_name, taskMessage,
text): text, internal=False):
# if more than 20 entries in the list, clean the list # if more than 20 entries in the list, clean the list
self.doLock.acquire() self.doLock.acquire()
if self.last >= 20: if self.last >= 20:
self._delete_completed_tasks() self._delete_completed_tasks()
if internal:
self.current-= 1
# progress, runtime, and status = 0 # progress, runtime, and status = 0
self.id += 1 self.id += 1
self.queue.append({'subject':subject, 'attachment':attachment, 'filepath':filepath, self.queue.append({'subject':subject, 'attachment':attachment, 'filepath':filepath,