File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3535log = logging .getLogger ("can.bcm" )
3636
3737NANOSECONDS_IN_SECOND : Final [int ] = 1_000_000_000
38- NANOSECONDS_IN_MILLISECOND : Final [int ] = 1_000_000
3938
4039
4140class CyclicTask (abc .ABC ):
@@ -316,19 +315,19 @@ def _run(self) -> None:
316315 self .stop ()
317316 break
318317
319- msg_due_time_ns += self .period_ns
318+ if not USE_WINDOWS_EVENTS :
319+ msg_due_time_ns += self .period_ns
320320 if self .end_time is not None and time .perf_counter () >= self .end_time :
321321 break
322322 msg_index = (msg_index + 1 ) % len (self .messages )
323323
324- # Compensate for the time it takes to send the message
325- delay_ns = msg_due_time_ns - time .perf_counter_ns ()
326-
327- if delay_ns > 0 :
328- if USE_WINDOWS_EVENTS :
329- win32event .WaitForSingleObject (
330- self .event .handle ,
331- int (round (delay_ns / NANOSECONDS_IN_MILLISECOND )),
332- )
333- else :
324+ if USE_WINDOWS_EVENTS :
325+ win32event .WaitForSingleObject (
326+ self .event .handle ,
327+ win32event .INFINITE ,
328+ )
329+ else :
330+ # Compensate for the time it takes to send the message
331+ delay_ns = msg_due_time_ns - time .perf_counter_ns ()
332+ if delay_ns > 0 :
334333 time .sleep (delay_ns / NANOSECONDS_IN_SECOND )
You can’t perform that action at this time.
0 commit comments