allow better console handling; download is low-pri thread

This commit is contained in:
David Rose 2009-10-09 01:06:06 +00:00
parent fdaca46eb9
commit f3e620677e
3 changed files with 11 additions and 8 deletions

View File

@ -79,6 +79,7 @@ class AppRunner(DirectObject):
# setP3DFilename() is called. # setP3DFilename() is called.
self.allowPythonDev = False self.allowPythonDev = False
self.interactiveConsole = False self.interactiveConsole = False
self.initialAppImport = False
self.sessionId = 0 self.sessionId = 0
self.packedAppEnvironmentInitialized = False self.packedAppEnvironmentInitialized = False
@ -368,7 +369,7 @@ class AppRunner(DirectObject):
except: except:
# Some unexpected Python exception; pass it to the # Some unexpected Python exception; pass it to the
# optional handler, if it is defined. # optional handler, if it is defined.
if self.exceptionHandler: if self.exceptionHandler and not self.interactiveConsole:
self.exceptionHandler() self.exceptionHandler()
else: else:
raise raise
@ -431,19 +432,18 @@ class AppRunner(DirectObject):
if mainName: if mainName:
moduleName = mainName moduleName = mainName
# Temporarily clear this flag while we import the app, so # Temporarily set this flag while we import the app, so
# that if the app calls run() within its own main.py, it # that if the app calls run() within its own main.py, it
# will properly get ignored by ShowBase. # will properly get ignored by ShowBase.
interactiveConsole = self.interactiveConsole self.initialAppImport = True
self.interactiveConsole = False
__import__(moduleName) __import__(moduleName)
main = sys.modules[moduleName] main = sys.modules[moduleName]
if hasattr(main, 'main') and callable(main.main): if hasattr(main, 'main') and callable(main.main):
main.main(self) main.main(self)
# Now restore this flag. # Now clear this flag.
self.interactiveConsole = interactiveConsole self.initialAppImport = False
if self.interactiveConsole: if self.interactiveConsole:
# At this point, we have successfully loaded the app. # At this point, we have successfully loaded the app.

View File

@ -3,6 +3,7 @@ from direct.stdpy.threading import Lock
from direct.showbase.MessengerGlobal import messenger from direct.showbase.MessengerGlobal import messenger
from direct.task.TaskManagerGlobal import taskMgr from direct.task.TaskManagerGlobal import taskMgr
from direct.p3d.PackageInfo import PackageInfo from direct.p3d.PackageInfo import PackageInfo
from pandac.PandaModules import TPLow
class PackageInstaller(DirectObject): class PackageInstaller(DirectObject):
@ -145,7 +146,8 @@ class PackageInstaller(DirectObject):
# If the task chain hasn't yet been set up, create the # If the task chain hasn't yet been set up, create the
# default parameters now. # default parameters now.
if not taskMgr.hasTaskChain(self.taskChain): if not taskMgr.hasTaskChain(self.taskChain):
taskMgr.setupTaskChain(self.taskChain, numThreads = 1) taskMgr.setupTaskChain(self.taskChain, numThreads = 1,
threadPriority = TPLow)
self.callbackLock = Lock() self.callbackLock = Lock()
self.calledDownloadStarted = False self.calledDownloadStarted = False

View File

@ -2473,7 +2473,8 @@ class ShowBase(DirectObject.DirectObject):
# p3d file. When we *are* within a p3d file, the Panda # p3d file. When we *are* within a p3d file, the Panda
# runtime has to be responsible for running the main loop, so # runtime has to be responsible for running the main loop, so
# we can't allow the application to do it. # we can't allow the application to do it.
if self.appRunner is None or self.appRunner.dummy or self.appRunner.interactiveConsole: if self.appRunner is None or self.appRunner.dummy or \
(self.appRunner.interactiveConsole and not self.appRunner.initialAppImport):
self.taskMgr.run() self.taskMgr.run()