Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auto Runtime.stop() #38

Merged
merged 8 commits into from
Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/lava/magma/core/process/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ def __init__(self, **kwargs):
# Current runtime environment
self._runtime: ty.Optional[Runtime] = None

def __del__(self):
"""On destructor call automatically
mgkwill marked this conversation as resolved.
Show resolved Hide resolved
stop the process.
"""
self.stop()

def _post_init(self):
"""Called after __init__() method of any sub class via
ProcessMetaClass to finalize initialization leading to following
Expand Down
7 changes: 7 additions & 0 deletions src/lava/magma/runtime/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ def __init__(self,
self.service_to_runtime_data: ty.Iterable[CspRecvPort] = []
self.runtime_to_service_data: ty.Iterable[CspSendPort] = []

def __del__(self):
"""On destructor call automatically
mgkwill marked this conversation as resolved.
Show resolved Hide resolved
stop the Runtime.
"""
if self._is_started:
self.stop()

def initialize(self):
"""Initializes the runtime"""
# Right now assume there is only 1 node config
Expand Down