mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-10 05:22:15 +03:00
added task base
This commit is contained in:
parent
e082797042
commit
5656c8764b
4 changed files with 50 additions and 0 deletions
25
opt/ahenk/base/task/TaskInQueue.py
Normal file
25
opt/ahenk/base/task/TaskInQueue.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
|
||||
|
||||
import threading
|
||||
from base.task.TaskJob import TaskJob
|
||||
|
||||
class TaskInQueue(threading.Thread):
|
||||
"""docstring for TaskInQueue"""
|
||||
def __init__(self,inQueue):
|
||||
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
|
16
opt/ahenk/base/task/TaskJob.py
Normal file
16
opt/ahenk/base/task/TaskJob.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
|
||||
import threading
|
||||
from base.Scope import Scope
|
||||
|
||||
class TaskJob(threading.Thread):
|
||||
"""docstring for TaskJob"""
|
||||
def __init__(self, task):
|
||||
super(TaskJob, self).__init__()
|
||||
scope = Scope.getInstance()
|
||||
self.task = task
|
||||
self.pluginManager = scope.getPluginManager()
|
||||
|
||||
def run(self):
|
||||
self.pluginManager.process(self.task)
|
9
opt/ahenk/base/task/TaskManager.py
Normal file
9
opt/ahenk/base/task/TaskManager.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# Author: İsmail BAŞARAN <ismail.basaran@tubitak.gov.tr> <basaran.ismaill@gmail.com>
|
||||
|
||||
class TaskManager(object):
|
||||
"""docstring for TaskManager"""
|
||||
def __init__(self):
|
||||
super(TaskManager, self).__init__()
|
||||
|
0
opt/ahenk/base/task/__init__.py
Normal file
0
opt/ahenk/base/task/__init__.py
Normal file
Loading…
Reference in a new issue