From 196c192479e9f694abbcf9503eb24be4480a7113 Mon Sep 17 00:00:00 2001 From: Arctic4161 <64910295+Arctic4161@users.noreply.github.com> Date: Sat, 16 Oct 2021 17:10:20 -0500 Subject: [PATCH] Update backend.py Added print locks so threads aren't printing over each other --- src/backend.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/backend.py b/src/backend.py index 991299b..9085ecf 100644 --- a/src/backend.py +++ b/src/backend.py @@ -9,11 +9,14 @@ from colorama import Fore from random import choice from requests.exceptions import Timeout import time +from threading import Semaphore OK = f"{Fore.RESET}[{Fore.GREEN}+{Fore.RESET}] " ERR = f"{Fore.RESET}[{Fore.RED}-{Fore.RESET}] " IN = f"{Fore.RESET}[{Fore.LIGHTBLUE_EX}>{Fore.RESET}] " +screenlock = Semaphore(value=1) + def random_headers(): desktop_agents = [ @@ -178,12 +181,18 @@ class CustomMessage(Exception): workingepisode: str = None def print_error(self): + screenlock.acquire() print(ERR, self.message, end=' ') + screenlock.release() def qual_not_found(self): + screenlock.acquire() print( f"{ERR}Episode {self.workingepisode} {Fore.LIGHTCYAN_EX}{self.episode_quality}{Fore.RESET} quality not found.") + screenlock.release() def use_default_qual(self): + screenlock.acquire() print( f"{OK}Trying {Fore.LIGHTCYAN_EX}{self.episode_quality}{Fore.RESET} quality for Episode {self.workingepisode}.") + screenlock.release()