Ahenk/opt/ahenk/base/task/task_in_queue.py

29 lines
787 B
Python
Raw Normal View History

2016-02-29 17:13:39 +02:00
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
import threading
2016-02-29 17:13:39 +02:00
from base.task.TaskJob import TaskJob
2016-02-29 17:13:39 +02:00
class TaskInQueue(threading.Thread):
"""docstring for TaskInQueue"""
def __init__(self, inQueue):
2016-02-29 17:13:39 +02:00
super(TaskInQueue, self).__init__()
self.inQueue = inQueue
def run(self):
# Add task to db. Adding task to db important because task can be lost when processing.
# Call plugin manager and process message inside task job
try:
task = self.inQueue.get()
print(task)
# Can be validate task before processing
job = TaskJob(task)
job.start()
except Exception as e:
raise