From cff07bd8d5a276eb3d27b8ad0a79f1e5ac987ed5 Mon Sep 17 00:00:00 2001 From: Oscuro87 Date: Tue, 28 Jan 2020 15:48:16 +0100 Subject: [PATCH 1/5] Candidate fix for https://github.com/evennia/evennia/issues/2039\#issue-555828740 --- evennia/scripts/scripts.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/evennia/scripts/scripts.py b/evennia/scripts/scripts.py index 3881d4971a..977dcb451b 100644 --- a/evennia/scripts/scripts.py +++ b/evennia/scripts/scripts.py @@ -139,6 +139,9 @@ class ExtendedLoopingCall(LoopingCall): if self.running: total_runtime = self.clock.seconds() - self.starttime interval = self.start_delay or self.interval + # Fairly naive ZeroDivision error bug workaround, see ticket: https://github.com/evennia/evennia/issues/2039#issue-555828740 + if self.interval == 0: + self.interval = 1 return interval - (total_runtime % self.interval) return None @@ -564,10 +567,7 @@ class DefaultScript(ScriptBase): Restarts an already existing/running Script from the beginning, optionally using different settings. This will first call the stop hooks, and then the start hooks again. - - Args: - interval (int, optional): Allows for changing the interval - of the Script. Given in seconds. if `None`, will use the +it should not accept 0 at alln seconds. if `None`, will use the already stored interval. repeats (int, optional): The number of repeats. If unset, will use the previous setting. @@ -586,7 +586,8 @@ class DefaultScript(ScriptBase): del self.db._manual_pause del self.db._paused_callcount # set new flags and start over - if interval is not None: + # Avoid intervals lower than zero + if interval is not None and interval >= 0: self.interval = interval if repeats is not None: self.repeats = repeats From bc8a1320d7058605581c7f81161ee707e4991b22 Mon Sep 17 00:00:00 2001 From: Oscuro87 Date: Tue, 28 Jan 2020 16:06:06 +0100 Subject: [PATCH 2/5] Second candidate fix for https://github.com/evennia/evennia/issues/2039\#issue-555828740 --- evennia/scripts/scripts.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/evennia/scripts/scripts.py b/evennia/scripts/scripts.py index 977dcb451b..a0136ccfba 100644 --- a/evennia/scripts/scripts.py +++ b/evennia/scripts/scripts.py @@ -136,12 +136,9 @@ class ExtendedLoopingCall(LoopingCall): the task is not running. """ - if self.running: + if self.running and self.interval > 0: total_runtime = self.clock.seconds() - self.starttime interval = self.start_delay or self.interval - # Fairly naive ZeroDivision error bug workaround, see ticket: https://github.com/evennia/evennia/issues/2039#issue-555828740 - if self.interval == 0: - self.interval = 1 return interval - (total_runtime % self.interval) return None @@ -586,7 +583,6 @@ it should not accept 0 at alln seconds. if `None`, will use the del self.db._manual_pause del self.db._paused_callcount # set new flags and start over - # Avoid intervals lower than zero if interval is not None and interval >= 0: self.interval = interval if repeats is not None: From 285cb420dc190e092cbdbc2be3263a410ad9f0fa Mon Sep 17 00:00:00 2001 From: Oscuro87 Date: Tue, 28 Jan 2020 16:14:57 +0100 Subject: [PATCH 3/5] Thid candidate fix for https://github.com/evennia/evennia/issues/2039\#issue-555828740 --- evennia/scripts/scripts.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/evennia/scripts/scripts.py b/evennia/scripts/scripts.py index a0136ccfba..89ff50b10a 100644 --- a/evennia/scripts/scripts.py +++ b/evennia/scripts/scripts.py @@ -583,7 +583,9 @@ it should not accept 0 at alln seconds. if `None`, will use the del self.db._manual_pause del self.db._paused_callcount # set new flags and start over - if interval is not None and interval >= 0: + if interval is not None: + if interval < 0: + interval = 0 self.interval = interval if repeats is not None: self.repeats = repeats From 0e2994203a59672b5842748152b13580ff9c6383 Mon Sep 17 00:00:00 2001 From: Oscuro87 Date: Tue, 28 Jan 2020 16:30:36 +0100 Subject: [PATCH 4/5] Fix a comment I broke --- evennia/scripts/scripts.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/evennia/scripts/scripts.py b/evennia/scripts/scripts.py index 89ff50b10a..f89fcb2d67 100644 --- a/evennia/scripts/scripts.py +++ b/evennia/scripts/scripts.py @@ -564,8 +564,9 @@ class DefaultScript(ScriptBase): Restarts an already existing/running Script from the beginning, optionally using different settings. This will first call the stop hooks, and then the start hooks again. -it should not accept 0 at alln seconds. if `None`, will use the - already stored interval. + Args: + interval (int, optional): Allows for changing the interval + of the Script. Given in seconds. if `None`, will use the repeats (int, optional): The number of repeats. If unset, will use the previous setting. start_delay (bool, optional): If we should wait `interval` seconds From e8dc8a93d330ab0df89388532dcb0a46948ff04a Mon Sep 17 00:00:00 2001 From: Oscuro87 Date: Tue, 28 Jan 2020 16:31:30 +0100 Subject: [PATCH 5/5] Fix a comment I broke, part 2... --- evennia/scripts/scripts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evennia/scripts/scripts.py b/evennia/scripts/scripts.py index f89fcb2d67..1326b4ffec 100644 --- a/evennia/scripts/scripts.py +++ b/evennia/scripts/scripts.py @@ -566,7 +566,7 @@ class DefaultScript(ScriptBase): first call the stop hooks, and then the start hooks again. Args: interval (int, optional): Allows for changing the interval - of the Script. Given in seconds. if `None`, will use the + of the Script. Given in seconds. if `None`, will use the already stored interval. repeats (int, optional): The number of repeats. If unset, will use the previous setting. start_delay (bool, optional): If we should wait `interval` seconds