Python3 Updates
This commit is contained in:
parent
190a70532a
commit
50164a92c6
7 changed files with 26 additions and 10 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -9,3 +9,4 @@
|
|||
*.pyc
|
||||
*build*
|
||||
test/output/*
|
||||
/.idea/*
|
||||
|
|
|
|||
|
|
@ -15,7 +15,10 @@
|
|||
|
||||
from pypdevs.simulator import Simulator
|
||||
|
||||
try:
|
||||
from Tkinter import *
|
||||
except ImportError:
|
||||
from tkinter import *
|
||||
from trafficLightModel import *
|
||||
|
||||
isBlinking = None
|
||||
|
|
|
|||
|
|
@ -15,7 +15,10 @@
|
|||
|
||||
from pypdevs.simulator import Simulator
|
||||
|
||||
try:
|
||||
from Tkinter import *
|
||||
except ImportError:
|
||||
from tkinter import *
|
||||
from trafficLightModel import *
|
||||
|
||||
isBlinking = None
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@
|
|||
import pypdevs.accurate_time as time
|
||||
from threading import Lock
|
||||
|
||||
_GLLOCK = Lock()
|
||||
|
||||
|
||||
class ThreadingGameLoop(object):
|
||||
"""
|
||||
Game loop subsystem for realtime simulation. Time will only progress when a *step* call is made.
|
||||
|
|
@ -30,6 +33,7 @@ class ThreadingGameLoop(object):
|
|||
"""
|
||||
Perform a step in the simulation. Actual processing is done in a seperate thread.
|
||||
"""
|
||||
with _GLLOCK: # Thread-safety
|
||||
if time.time() >= self.next_event:
|
||||
self.next_event = float('inf')
|
||||
getattr(self, "func")()
|
||||
|
|
|
|||
|
|
@ -144,7 +144,9 @@ class DEVSException(Exception):
|
|||
"""
|
||||
String representation of the exception
|
||||
"""
|
||||
if hasattr(self, "message"):
|
||||
return "DEVS Exception: " + str(self.message)
|
||||
return "DEVS Exception: " + str(self.args[0])
|
||||
|
||||
class QuickStopException(Exception):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -185,7 +185,10 @@ elif mn.startswith("realtime"):
|
|||
elif mn.startswith("realtime_loop"):
|
||||
args["setRealTimePlatformGameLoop"] = []
|
||||
elif mn.startswith("realtime_tk"):
|
||||
try:
|
||||
from Tkinter import *
|
||||
except ImportError:
|
||||
from tkinter import *
|
||||
myTk = Tk()
|
||||
args["setRealTimePlatformTk"] = [myTk]
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class TraceDumper(threading.Thread):
|
|||
pass
|
||||
|
||||
def stacktraces(self):
|
||||
fout = file(self.fpath,"wb+")
|
||||
fout = open(self.fpath,"wb+")
|
||||
try:
|
||||
fout.write(stacktraces())
|
||||
finally:
|
||||
|
|
@ -97,5 +97,5 @@ def trace_stop():
|
|||
if _tracer is None:
|
||||
raise Exception("Not tracing, cannot stop.")
|
||||
else:
|
||||
_trace.stop()
|
||||
_trace = None
|
||||
_tracer.stop()
|
||||
_tracer = None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue