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

feat: added shutdown method to CCHannel [ready for review] #310

Merged
merged 2 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions src/pykiso/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ def close(self) -> None:
with self._lock:
self._cc_close()

def shutdown(self) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You add a specific need for the PCAN connectror into the base connector class.

I don't think it's the right place

"""Unitialize channel."""
flo117 marked this conversation as resolved.
Show resolved Hide resolved
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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)):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition specific implementation of a behavior only needed for the PCAN.

Maybe a solution would be to decorate the close method for the PCAN connector to handle the trace creation.

As mentioned above, even before with the del implementation, it's not the right place

instance.shutdown()


class AuxiliaryCache(ModuleCache):
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
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