Skip to content

Commit 1381252

Browse files
author
Günther Jena
committed
add stop for CANBusNetwork
1 parent c551463 commit 1381252

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 0.4.8
2+
3+
* adding .stop method to CANBusNetwork
4+
* remove .shutdown method from scheduler base class and add .stop to SyncScheduler
5+
16
# 0.4.7
27

38
* adding .shutdown method to schedulers

src/durand/network.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(self, can_bus: can.BusABC, loop=None):
3838
self.subscriptions: Dict[int, Callable[[int, bytes], None]] = {}
3939

4040
listener = NodeListener(self)
41-
can.Notifier(self._bus, (listener,), 1, self._loop)
41+
self._notifier = can.Notifier(self._bus, (listener,), 1, self._loop)
4242

4343
def add_subscription(self, cob_id: int, callback):
4444
with self.lock:
@@ -58,6 +58,9 @@ def _update_filters(self):
5858
def send(self, cob_id: int, msg: bytes):
5959
msg = can.Message(arbitration_id=cob_id, data=msg, is_extended_id=False)
6060
self._bus.send(msg)
61+
62+
def stop(self):
63+
self._notifier.stop()
6164

6265

6366
class NodeListener(can.Listener):

src/durand/scheduler.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ def cancel(self, entry: TEntry):
3434
def lock(self):
3535
"""A global lock which can be used the assure thread safety"""
3636

37-
def shutdown(self):
38-
""" Shutting down the scheduler """
39-
4037

4138
class AsyncScheduler(AbstractScheduler):
4239
def __init__(self, loop=None):
@@ -60,8 +57,6 @@ def cancel(self, entry: asyncio.TimerHandle): # type: ignore[override]
6057
def lock(self):
6158
return self._lock
6259

63-
# nothing happens at shutdown, as no resources have to be freed
64-
6560

6661
class SyncScheduler(AbstractScheduler):
6762
def __init__(self, lock: threading.Lock = None):
@@ -96,7 +91,7 @@ def run(self):
9691
def lock(self):
9792
return self._lock
9893

99-
def shutdown(self):
94+
def stop(self):
10095
self._wake_up.set()
10196
self._stop = True
10297

0 commit comments

Comments
 (0)