39 lines
No EOL
1.1 KiB
Python
39 lines
No EOL
1.1 KiB
Python
from multiprocessing import Process
|
|
from typing import NoReturn
|
|
|
|
from classes.vessel import Vessel
|
|
|
|
import time
|
|
|
|
|
|
class VesselThread(Process):
|
|
"""Thread processing uploads to a single vessel
|
|
"""
|
|
|
|
def __init__(self, vessel: Vessel, state: dict) -> None:
|
|
"""Initialize a new VesselThread
|
|
|
|
Args:
|
|
vessel (classes.vessel.Vessel): Vessel object to handle uploads for
|
|
state (dict): Dictionary containing the current application state
|
|
"""
|
|
super().__init__()
|
|
self.vessel = vessel
|
|
self._state = state
|
|
|
|
def run(self) -> NoReturn:
|
|
"""Run thread and process uploads to the vessel
|
|
"""
|
|
print("Launched Vessel Thread for " + self.vessel.name)
|
|
while True:
|
|
try:
|
|
self.processQueue()
|
|
except Exception as e:
|
|
print("An exception occurred in the Vessel Thread for " +
|
|
self.vessel.name)
|
|
print(repr(e))
|
|
|
|
def processQueue(self) -> None:
|
|
for f in self._state["files"]:
|
|
if not f.uuid in self.vessel._uploaded:
|
|
pass |