Allow RestartableCyclicTaskABC using Windows events to restart by pierreluctg · Pull Request #1679 · hardbyte/python-can
Allow RestartableCyclicTaskABC using Windows events to restart
Also adding unit test to cover RestartableCyclicTaskABC and avoid this type of bug.
@zariiii9003 please review and consider for a bug fix release.
Semi-related: Could you check why the SimpleCyclicSendTaskTest test is so slow after #1666?
I assume win32event.INFINITE might be a problem, when the timer gets cancelled. Maybe we could just set a multiple of the requested cycle time as the timeout.
Second edit: The win32event.INFINITE is the reason why self.thread.is_alive() returns True when you try to restart.
Also adding unit test to cover RestartableCyclicTaskABC
@zariiii9003 please have another look. This should address the issues.
The
CancelWaitableTimerfunction does not change the signaled state of the timer.
So the thread was waiting for ever (win32event.INFINITE) on the cancled event.
This change replace CancelWaitableTimer by SetWaitableTimer with a period of 0.
This is documented in the SetWaitableTimer API doc.
A periodic timer automatically reactivates each time the period elapses, until the timer is canceled using the CancelWaitableTimer function or reset using SetWaitableTimer.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. The reset with SetWaitableTimer is a nice solution.
mergify
bot
deleted the
bcm-win-event-resume-bug
branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters