Skip to content

Commit 505c33f

Browse files
committed
add flag to know when guardian is setup
Signed-off-by: Sylvain Hellegouarch <[email protected]>
1 parent d60534f commit 505c33f

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22

33
## [Unreleased][]
44

5-
[Unreleased]: https://github.com/chaostoolkit/chaostoolkit-addons/compare/0.6.0...HEAD
5+
[Unreleased]: https://github.com/chaostoolkit/chaostoolkit-addons/compare/0.7.0...HEAD
6+
7+
## [0.7.0][]
8+
9+
[0.7.0]: https://github.com/chaostoolkit/chaostoolkit-addons/compare/0.6.0...0.7.0
10+
11+
### Changed
12+
13+
- Added a flag to know when the guardian was fully setup
614

715
## [0.6.0][]
816

chaosaddons/controls/safeguards.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class Guardian:
110110
def __init__(self) -> None:
111111
self._lock = threading.Lock()
112112
self._interrupted = False
113+
self._setup = False
113114

114115
@property
115116
def interrupted(self) -> bool:
@@ -148,6 +149,7 @@ def prepare(self, probes: List[Probe]) -> None:
148149
self.now = ThreadPoolExecutor(max_workers=now_count or 1)
149150
self.once = ThreadPoolExecutor(max_workers=once_count or 1)
150151
self.repeating = ThreadPoolExecutor(max_workers=repeating_count or 1)
152+
self._setup = True
151153

152154
def run(self, experiment: Experiment, probes: List[Probe],
153155
configuration: Configuration, secrets: Secrets,
@@ -201,6 +203,9 @@ def terminate(self) -> None:
201203
"""
202204
Stop the guardian and all its safeguards.
203205
"""
206+
if not self._setup:
207+
return None
208+
204209
self.repeating_until.set()
205210
self.now.shutdown(wait=True)
206211
self.repeating.shutdown(wait=True)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
setup(
66
use_scm_version=True,
77
name="chaostoolkit-addons",
8-
version="0.6.0",
8+
version="0.7.0",
99
)

0 commit comments

Comments
 (0)