From 45cd8b8a002447fbcc01e2e3d0b76218eacffcb0 Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Fri, 30 Sep 2016 00:35:31 -0700 Subject: [PATCH] Cleanup kill script --- plexpy/notifiers.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plexpy/notifiers.py b/plexpy/notifiers.py index f3301143..df691836 100644 --- a/plexpy/notifiers.py +++ b/plexpy/notifiers.py @@ -2163,23 +2163,23 @@ class Scripts(object): return scripts def run_script(self, script): + def kill_script(process): + logger.warn(u"PlexPy Notifiers :: Script exceeded timeout limit of %d seconds. " + "Script killed." % self.script_timeout) + process.kill() + self.script_killed = True + + self.script_killed = False output = error = '' try: - def kill_script(process): - logger.warn(u"PlexPy Notifiers :: Script exceeded timeout limit of %d seconds. " - "Script killed." % self.script_timeout) - process.kill() - self.script_killed = True process = subprocess.Popen(script, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - cwd=plexpy.CONFIG.SCRIPTS_FOLDER) + cwd=self.script_folder) timer = threading.Timer(self.script_timeout, kill_script, (process,)) - self.script_killed = False - try: timer.start() output, error = process.communicate()