Skip to content

Commit

Permalink
Merge pull request #5 from lagmoellertim/development
Browse files Browse the repository at this point in the history
Multiple Bug Fixes
  • Loading branch information
Tim-Luca Lagmöller authored Jun 10, 2020
2 parents 7382dd8 + cf6eaa8 commit ee623c9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name='unsilence',
version='1.0.1',
version='1.0.2',
install_requires=requirements,
license='MIT License',
author='Tim-Luca Lagmöller',
Expand Down
10 changes: 5 additions & 5 deletions unsilence/command_line/EntryPoint.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import sys

from rich.console import Console
Expand All @@ -8,6 +7,7 @@
from unsilence.command_line.ChoiceDialog import choice_dialog
from unsilence.command_line.ParseArguments import parse_arguments
from unsilence.command_line.PrettyTimeEstimate import pretty_time_estimate
from unsilence.command_line.TerminalSupport import repair_console


def main():
Expand All @@ -16,14 +16,13 @@ def main():
:return: None
"""
try:
repair_console()
run()
except KeyboardInterrupt:
print("\nInterrupted")

try:
sys.exit(0)
except SystemExit:
os._exit(0)
repair_console()
sys.exit(0)


def run():
Expand Down Expand Up @@ -108,3 +107,4 @@ def handler(current_val, total):
progress.stop()

console.print("\n[green]Finished![/green] :tada:")
print()
6 changes: 6 additions & 0 deletions unsilence/command_line/TerminalSupport.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import os


def repair_console():
if os.name == "posix":
os.system("stty sane")
12 changes: 9 additions & 3 deletions unsilence/lib/render_media/MediaRenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def render(self, input_file: Path, output_file: Path, intervals: Intervals, **kw
task_queue = queue.Queue()
thread_list = []
completed_tasks = []
corrupted_intervals = []

def handle_thread_completed_task(completed_task, corrupted):
"""
Expand All @@ -82,12 +83,17 @@ def handle_thread_completed_task(completed_task, corrupted):
:return: None
"""
func = kwargs.get("on_render_progress_update", None)

thread_lock.acquire()

if not corrupted:
thread_lock.acquire()
completed_tasks.append(completed_task)
if func is not None:
func(len(completed_tasks), len(intervals.intervals))
thread_lock.release()
else:
corrupted_intervals.append(completed_task)

thread_lock.release()

for i in range(kwargs.get("threads", 2)):
thread = RenderIntervalThread(i, input_file, render_options, task_queue, thread_lock,
Expand All @@ -107,7 +113,7 @@ def handle_thread_completed_task(completed_task, corrupted):
task_queue.put(task)
thread_lock.release()

while not task_queue.empty() or len(completed_tasks) != len(intervals.intervals):
while len(completed_tasks) < (len(intervals.intervals) - len(corrupted_intervals)):
time.sleep(0.5)

for thread in thread_list:
Expand Down

0 comments on commit ee623c9

Please sign in to comment.