Commit 584d2e64 authored by Cristiano Urban's avatar Cristiano Urban
Browse files

Added 'RetrievePreprocessor' class skeleton.

parent e94c233f
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
from config import Config
from db_connector import DbConnector
from task_executor import TaskExecutor


class RetrievePreprocessor(TaskExecutor):

    def __init__(self):
        config = Config("vos_ts.conf")
        self.params = config.loadSection("file_catalog")
        self.dbConn = DbConnector(self.params["user"],
                                  self.params["password"],
                                  self.params["host"],
                                  self.params.getint("port"),
                                  self.params["db"])
        super(RetrievePreprocessor, self).__init__()

    def run(self):
        print("Starting retrieve preprocessor...")
        self.setSourceQueueName("read_pending")
        self.setDestinationQueueName("read_ready")
        while True:
            self.wait()
            if self.destQueue.len() < self.maxReadyJobs and self.srcQueue.len() > 0:
                self.jobObj = self.srcQueue.getJob()                
                
                # do something here...
                
                self.srcQueue.extractJob()
                self.destQueue.insertJob(self.jobObj)
                print(f"Job {self.jobObj.jobId} MOVED from {self.srcQueue.name()} to {self.destQueue.name()}")
 No newline at end of file