From 88e1d143046a7248daddd3a3ab875bcff38c0781 Mon Sep 17 00:00:00 2001 From: SuperSonic Date: Fri, 28 Feb 2020 20:53:08 +0800 Subject: [PATCH] Resolved mds exit problem --- libs/poll.py | 1 - libs/thread_control.py | 16 +++++++++++----- libs/tools.py | 1 - libs/yuuki.py | 4 +++- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/libs/poll.py b/libs/poll.py index 22a2b4a..e513101 100644 --- a/libs/poll.py +++ b/libs/poll.py @@ -6,7 +6,6 @@ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. """ - import socket import time diff --git a/libs/thread_control.py b/libs/thread_control.py index 489efc7..35ddff9 100644 --- a/libs/thread_control.py +++ b/libs/thread_control.py @@ -15,8 +15,8 @@ class Yuuki_Thread: self.lock = threading.Lock() @staticmethod - def add(Yuuki_Func, args=()): - added_thread = threading.Thread(name=Yuuki_Func.__name__, target=Yuuki_Func, args=args) + def add(function, args=()): + added_thread = threading.Thread(name=function.__name__, target=function, args=args) added_thread.start() @staticmethod @@ -27,7 +27,13 @@ class Yuuki_Thread: class Yuuki_Multiprocess: - @staticmethod - def add(Yuuki_Func, args=()): - added_multiprocess = multiprocessing.Process(name=Yuuki_Func.__name__, target=Yuuki_Func, args=args) + multiprocess_list = {} + + def add(self, function, args=()): + added_multiprocess = multiprocessing.Process(name=function.__name__, target=function, args=args) + self.multiprocess_list[function.__name__] = added_multiprocess added_multiprocess.start() + + def stop(self, function_name): + assert function_name in self.multiprocess_list + self.multiprocess_list[function_name].terminate() diff --git a/libs/tools.py b/libs/tools.py index 6d32f16..4f2bb20 100644 --- a/libs/tools.py +++ b/libs/tools.py @@ -6,7 +6,6 @@ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. """ - import json import ntpath import os diff --git a/libs/yuuki.py b/libs/yuuki.py index 025dbd9..a526d2e 100644 --- a/libs/yuuki.py +++ b/libs/yuuki.py @@ -6,9 +6,9 @@ This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. """ - import os import platform +import time import random from git import Repo @@ -130,6 +130,8 @@ class Yuuki: self.data.updateData(["Global", "Power"], False) if self.Threading: self.data.mdsShake("EXT", None, None) + time.sleep(1) + self.data.MdsThreadControl.stop("listen") if self.YuukiConfigs.get("WebAdmin"): self.webAdmin.stop() if restart: