single use media archiving made usable again

This commit is contained in:
2022-10-29 17:18:41 +02:00
parent e6bfe811d0
commit 104b99df7e
3 changed files with 45 additions and 44 deletions

View File

@@ -128,8 +128,14 @@ class Dispatcher(Thread):
class PrintWorker:
def __init__(self, action, sent = False) -> None:
self.action = action
self.sent = sent
def send(self, article):
print(f"Uploaded article {article}")
print(f"{self.action} article {article}")
if self.sent:
article.sent = True
article.save()
def keep_alive(self): # keeps script running, because there is nothing else in the main thread
while True: sleep(1)
@@ -144,11 +150,12 @@ if __name__ == "__main__":
logger.info(f"Launching upload to archive for {len(articles)} articles.")
dispatcher.workers_in = [{"UploadWorker": UploadWorker()}]
dispatcher.workers_out = [{"PrintWorker": PrintWorker()}]
print_worker = PrintWorker("Uploaded")
dispatcher.workers_out = [{"PrintWorker": print_worker}]
dispatcher.start()
for a in articles:
dispatcher.incoming_request(article=a)
PrintWorker().keep_alive()
print_worker.keep_alive()
else: # launch with full action
try: