From a540b698e9f1d83c629c6be469e0c71fa8616951 Mon Sep 17 00:00:00 2001 From: K4YT3X Date: Tue, 23 Oct 2018 12:02:13 -0400 Subject: [PATCH] 2.0.3 added print thread lock to prevent printing format errors --- waifu2x.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/waifu2x.py b/waifu2x.py index 6e2f7c0..805cf77 100755 --- a/waifu2x.py +++ b/waifu2x.py @@ -9,7 +9,7 @@ Last Modified: October 22, 2018 Description: This class controls waifu2x engine -Version 2.0.2 +Version 2.0.3 """ from avalon_framework import Avalon import subprocess @@ -29,6 +29,7 @@ class Waifu2x: self.waifu2x_path = waifu2x_path self.method = method self.model_type = model_type + self.print_lock = threading.Lock() def upscale(self, folderin, folderout, width, height): """This is the core function for WAIFU2X class @@ -39,8 +40,18 @@ class Waifu2x: width {int} -- output video width height {int} -- output video height """ + + # Print thread start message + self.print_lock.acquire() Avalon.debug_info('[upscaler] Thread {} started'.format(threading.current_thread().name)) + self.print_lock.release() + + # Create string for execution execute = '{} -p {} -I png -i {} -e png -o {} -w {} -h {} -n 3 -m noise_scale -y {}'.format( self.waifu2x_path, self.method, folderin, folderout, width, height, self.model_type) subprocess.call(execute) + + # Print thread exiting message + self.print_lock.acquire() Avalon.debug_info('[upscaler] Thread {} exiting'.format(threading.current_thread().name)) + self.print_lock.release()