From cf9e195fff0668d68a27002409215a67bc8d124e Mon Sep 17 00:00:00 2001 From: Sepand Haghighi Date: Thu, 8 Feb 2024 10:20:05 +0330 Subject: [PATCH] Orphan processes (#35) * fix : tests modified * fix : tests modified * fix : minor bug in tests fixed * fix : tests modified * fix : tests modified * fix : tests modified * fix : tests modified * fix : NavaThread stop method bug fixed * doc : CHANGELOG.md updated * fix : tests updated --- CHANGELOG.md | 2 ++ nava/thread.py | 4 ++++ test/function_test.py | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68e804d..be67198 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- `NavaThread.stop` method bug fixed ## [0.3] - 2024-01-31 ### Added - `NavaThread` class diff --git a/nava/thread.py b/nava/thread.py index 2ebc988..8e504f8 100644 --- a/nava/thread.py +++ b/nava/thread.py @@ -41,5 +41,9 @@ def stop(self): winsound.PlaySound(None, winsound.SND_PURGE) else: if self.play_process is not None: + self.play_process.stdout.close() + self.play_process.stdin.close() + self.play_process.stderr.close() self.play_process.kill() self.play_process.terminate() + self.play_process.wait() diff --git a/test/function_test.py b/test/function_test.py index aab6559..058f1ed 100644 --- a/test/function_test.py +++ b/test/function_test.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- """ >>> import os +>>> import time >>> from nava import play, stop, stop_all >>> play(os.path.join("others", "test.wav")) >>> sound_id_1 = play(os.path.join("others", "test.wav"), async_mode=True) @@ -14,6 +15,10 @@ True >>> stop(1001) >>> stop_all() +>>> for i in range(40): +... sound_id = play(os.path.join("others", "test.wav"), async_mode=True) +... time.sleep(0.5) +... stop(sound_id) >>> from nava.functions import nava_help >>> nava_help()