Skip to content

Commit c712131

Browse files
authored
ThreadBasedCyclicSendTask using WIN32 API cannot handle period smaller than 1 ms (#1847)
Using a win32 SetWaitableTimer with a period of `0` means that the timer will only be signaled once. This will make the `ThreadBasedCyclicSendTask` to only send one message.
1 parent e291874 commit c712131

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

can/broadcastmanager.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ def __init__(
308308

309309
self.event: Optional[_Pywin32Event] = None
310310
if PYWIN32:
311+
if self.period_ms == 0:
312+
# A period of 0 would mean that the timer is signaled only once
313+
raise ValueError("The period cannot be smaller than 0.001 (1 ms)")
311314
self.event = PYWIN32.create_timer()
312315
elif (
313316
sys.platform == "win32"

0 commit comments

Comments
 (0)