fixed the issue where the encoder cannot exit

This commit is contained in:
k4yt3x 2022-08-28 15:03:16 +00:00
parent f7d6dc41b3
commit 29a55e633c
2 changed files with 5 additions and 11 deletions

View File

@ -19,7 +19,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
Name: Video Encoder Name: Video Encoder
Author: K4YT3X Author: K4YT3X
Date Created: June 17, 2021 Date Created: June 17, 2021
Last Modified: April 9, 2022 Last Modified: August 28, 2022
""" """
import os import os
@ -138,10 +138,6 @@ class VideoEncoder:
self.encoder.stdin.flush() self.encoder.stdin.flush()
self.encoder.stderr.flush() self.encoder.stderr.flush()
# send SIGINT (2) to FFmpeg
# this instructs it to finalize and exit
self.encoder.send_signal(signal.SIGINT)
# close PIPEs to prevent process from getting stuck # close PIPEs to prevent process from getting stuck
self.encoder.stdin.close() self.encoder.stdin.close()
self.encoder.stderr.close() self.encoder.stderr.close()

View File

@ -27,7 +27,7 @@ __ __ _ _ ___ __ __
Name: Video2X Name: Video2X
Creator: K4YT3X Creator: K4YT3X
Date Created: February 24, 2018 Date Created: February 24, 2018
Last Modified: April 30, 2022 Last Modified: August 28, 2022
Editor: BrianPetkovsek Editor: BrianPetkovsek
Last Modified: June 17, 2019 Last Modified: June 17, 2019
@ -332,11 +332,6 @@ class Video2X:
decoder_thread.stop() decoder_thread.stop()
decoder_thread.join() decoder_thread.join()
# stop the encoder
encoder.join()
logger.critical("ENCODER")
# clear queue and signal processors to exit # clear queue and signal processors to exit
# multiprocessing.Queue has no Queue.queue.clear # multiprocessing.Queue has no Queue.queue.clear
while tasks_queue.empty() is not True: while tasks_queue.empty() is not True:
@ -348,6 +343,9 @@ class Video2X:
processor_pool.close() processor_pool.close()
processor_pool.join() processor_pool.join()
# stop the encoder
encoder.join()
# restore original STDOUT and STDERR # restore original STDOUT and STDERR
sys.stdout = original_stdout sys.stdout = original_stdout
sys.stderr = original_stderr sys.stderr = original_stderr