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

ThreadBasedCyclicSendTask won't start again #1866

Closed
phettberg opened this issue Sep 29, 2024 · 0 comments · Fixed by #1871
Closed

ThreadBasedCyclicSendTask won't start again #1866

phettberg opened this issue Sep 29, 2024 · 0 comments · Fixed by #1871
Labels

Comments

@phettberg
Copy link

phettberg commented Sep 29, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant