File tree 2 files changed +17
-4
lines changed
2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change
1
+ import sys
1
2
import time
2
3
import threading
3
4
import math
14
15
RTR_NOT_ALLOWED = 1 << 30
15
16
16
17
18
+ if hasattr (time , "perf_counter" ):
19
+ # Choose time.perf_counter if available
20
+ timer = time .perf_counter
21
+ elif sys .platform == "win32" :
22
+ # On Windows, the best timer is time.clock
23
+ timer = time .clock
24
+ else :
25
+ # On most other platforms the best timer is time.time
26
+ timer = time .time
27
+
28
+
17
29
logger = logging .getLogger (__name__ )
18
30
19
31
@@ -363,13 +375,14 @@ def wait_for_reception(self, timeout=10):
363
375
364
376
def _periodic_transmit (self ):
365
377
while not self .stop_event .is_set ():
366
- start = time . time ()
378
+ start = timer ()
367
379
try :
368
380
self .transmit ()
369
381
except CanError as error :
370
382
print (str (error ))
371
- time_left = self .period - (time .time () - start )
372
- time .sleep (max (time_left , 0.0 ))
383
+ time_left = self .period - (timer () - start )
384
+ if time_left > 0 :
385
+ time .sleep (time_left )
373
386
374
387
375
388
class Variable (common .Variable ):
Original file line number Diff line number Diff line change 1
1
2
- __version__ = "0.4.0.dev5 "
2
+ __version__ = "0.4.0.dev6 "
You can’t perform that action at this time.
0 commit comments