contentmonster/classes/vesselthread.py

31 lines
887 B
Python
Raw Normal View History

2021-11-20 14:40:07 +00:00
from multiprocessing import Process
from typing import NoReturn
2021-11-20 14:40:07 +00:00
2021-11-25 15:31:49 +00:00
from classes.vessel import Vessel
2021-11-22 10:14:38 +00:00
import time
2021-11-20 14:40:07 +00:00
class VesselThread(Process):
2021-11-25 15:31:49 +00:00
"""Thread processing uploads to a single vessel
"""
def __init__(self, vessel: Vessel, state: dict) -> None:
2021-11-25 15:31:49 +00:00
"""Initialize a new VesselThread
Args:
vessel (classes.vessel.Vessel): Vessel object to handle uploads for
state (dict): Dictionary containing the current application state
"""
2021-11-20 14:40:07 +00:00
super().__init__()
self.vessel = vessel
2021-11-25 15:31:49 +00:00
self._state = state
2021-11-20 14:40:07 +00:00
def run(self) -> NoReturn:
2021-11-25 15:31:49 +00:00
"""Run thread and process uploads to the vessel
"""
2021-11-22 10:14:38 +00:00
print("Launched Vessel Thread for " + self.vessel.name)
while True:
try:
2021-11-25 15:31:49 +00:00
print(self._state["files"][0])
2021-11-22 10:14:38 +00:00
except:
2021-11-25 15:31:49 +00:00
pass
time.sleep(1)