File tree Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Original file line number Diff line number Diff line change 35
35
log = logging .getLogger ("can.bcm" )
36
36
37
37
NANOSECONDS_IN_SECOND : Final [int ] = 1_000_000_000
38
- NANOSECONDS_IN_MILLISECOND : Final [int ] = 1_000_000
39
38
40
39
41
40
class CyclicTask (abc .ABC ):
@@ -316,19 +315,19 @@ def _run(self) -> None:
316
315
self .stop ()
317
316
break
318
317
319
- msg_due_time_ns += self .period_ns
318
+ if not USE_WINDOWS_EVENTS :
319
+ msg_due_time_ns += self .period_ns
320
320
if self .end_time is not None and time .perf_counter () >= self .end_time :
321
321
break
322
322
msg_index = (msg_index + 1 ) % len (self .messages )
323
323
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
+ - 1 ,
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 :
334
333
time .sleep (delay_ns / NANOSECONDS_IN_SECOND )
You can’t perform that action at this time.
0 commit comments