Describe the bug
When instantiating ThreadBasedCyclicSendTask by calling bus.send_periodic, with a certain duration, the task won't start again after calling .start
The problem is, that self.end_time is only set at init in broadcastmanager.py
self.end_time: Optional[float] = (
time.perf_counter() + duration if duration else None
)
Then it only works the first time when the thread is started immediately
while not self.stopped:
if self.end_time is not None and time.perf_counter() >= self.end_time:
break
However, it should be set again, either in .start() or in _run().
I guess this might affect #1848 #1853 as well.
To Reproduce
- Create a
ThreadBasedCyclicSendTask object example_task by calling bus.send_periodic, including a modifier_callback and a duration of five seconds
- Wait five seconds
- Call
example_task.start()
- The task won't start
Expected behavior
The defined periodic task should start again, with the same duration and interval.
Additional context
OS and version: Ubuntu 24.04.1 LTS
Python version: 3.12.3
python-can version: 4.4.2
python-can interface/s (if applicable): socketcan and IXXAT
Traceback and logs
Describe the bug
When instantiating
ThreadBasedCyclicSendTaskby callingbus.send_periodic, with a certain duration, the task won't start again after calling.startThe problem is, that
self.end_timeis only set at init in broadcastmanager.pyThen it only works the first time when the thread is started immediately
However, it should be set again, either in
.start()or in_run().I guess this might affect #1848 #1853 as well.
To Reproduce
ThreadBasedCyclicSendTaskobjectexample_taskby callingbus.send_periodic, including amodifier_callbackand a duration of five secondsexample_task.start()Expected behavior
The defined periodic task should start again, with the same duration and interval.
Additional context
OS and version: Ubuntu 24.04.1 LTS
Python version: 3.12.3
python-can version: 4.4.2
python-can interface/s (if applicable): socketcan and IXXAT
Traceback and logs