Skip to content

Commit 8949fa7

Browse files
committed
Address Python 3.8 issues
1 parent bf0aeea commit 8949fa7

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

vpython/rate_control.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import time
2-
import platform
2+
try:
3+
_clock = time.perf_counter # time.clock is deprecated in Python 3.3, gone in 3.8
4+
except:
5+
_clock = time.clock
6+
_tick = 1/60
7+
8+
#import platform
39
import queue
410
import json
511

@@ -17,20 +23,20 @@
1723
INTERACT_PERIOD = 1.0/MAX_RENDERS
1824
USER_FRACTION = 0.5
1925

20-
_plat = platform.system()
21-
22-
if _plat == 'Windows':
23-
# On Windows, the best timer is supposedly time.clock()
24-
_clock = time.clock
25-
_tick = 1/60
26-
elif _plat == 'Macintosh':
27-
# On platforms other than Windows, the best timer is supposedly time.time()
28-
_clock = time.time
29-
_tick = 0.01
30-
else: # 'Unix'
31-
# On platforms other than Windows, the best timer is supposedly time.time()
32-
_clock = time.time
33-
_tick = 0.01 # though sleep seems to be accurate at the 1 millisecond level
26+
##_plat = platform.system()
27+
28+
##if _plat == 'Windows':
29+
## # On Windows, the best timer is supposedly time.clock()
30+
## _clock = time.clock
31+
## _tick = 1/60
32+
##elif _plat == 'Macintosh':
33+
## # On platforms other than Windows, the best timer is supposedly time.time()
34+
## _clock = time.time
35+
## _tick = 0.01
36+
##else: # 'Unix'
37+
## # On platforms other than Windows, the best timer is supposedly time.time()
38+
## _clock = time.time
39+
## _tick = 0.01 # though sleep seems to be accurate at the 1 millisecond level
3440

3541
##Possible way to get one-millisecond accuracy in sleep on Windows:
3642
##http://msdn.microsoft.com/en-us/library/windows/desktop/ms686298(v=vs.85).aspx

0 commit comments

Comments
 (0)