Skip to content

Commit

Permalink
feat: added shutdown method to CCHannel [ready for review] (eclipse#310)
Browse files Browse the repository at this point in the history
* feat: added shutdown method to CChannel interface

Co-authored-by: Sebastian Clerson <58192998+sebclrsn@users.noreply.github.com>

---------

Co-authored-by: Sebastian Clerson <58192998+sebclrsn@users.noreply.github.com>
  • Loading branch information
flo117 and sebclrsn committed Jun 19, 2023
1 parent 64c08b1 commit 450db2f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/pykiso/connector.py
Expand Up @@ -100,6 +100,10 @@ def close(self) -> None:
with self._lock:
self._cc_close()

def shutdown(self) -> None:
"""Unitialize channel. Will be called at the end of the test session."""
pass

def cc_send(self, msg: MsgType, *args, **kwargs) -> None:
"""Send a thread-safe message on the channel and wait for an acknowledgement.
Expand Down
2 changes: 1 addition & 1 deletion src/pykiso/lib/connectors/cc_pcan_can.py
Expand Up @@ -503,7 +503,7 @@ def _convert_peak_format_to_start_time(start_time: float) -> float:
ms_in_a_day = 86400000
return (start_time % 1) * ms_in_a_day

def __del__(self) -> None:
def shutdown(self) -> None:
"""Destructor method."""
if self.logging_activated:
self._merge_trc()
6 changes: 3 additions & 3 deletions src/pykiso/test_setup/dynamic_loader.py
Expand Up @@ -232,10 +232,10 @@ def get_instance(self, name: str) -> Union[AuxiliaryCommon, Connector]:
return inst

def delete_all_instances(self) -> None:
"""Call custom del method if it exists"""
"""Call shutdown method if it exists"""
for instance in self.instances.values():
if callable(getattr(instance, "__del__", None)):
instance.__del__()
if callable(getattr(instance, "shutdown", None)):
instance.shutdown()


class AuxiliaryCache(ModuleCache):
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Expand Up @@ -245,7 +245,7 @@ def __init__(self, *args, **kwargs):
super(TCChan, self).__init__(*args, **kwargs)
self.remote_id = None

def __del__(self):
def shutdown(self):
pass

_cc_open = mocker.stub(name="_cc_open")
Expand Down

0 comments on commit 450db2f

Please sign in to comment.