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.
self.allowPythonDev = False
self.interactiveConsole = False
self.initialAppImport = False
self.sessionId = 0
self.packedAppEnvironmentInitialized = False
@ -368,7 +369,7 @@ class AppRunner(DirectObject):
except:
# Some unexpected Python exception; pass it to the
# optional handler, if it is defined.
if self.exceptionHandler:
if self.exceptionHandler and not self.interactiveConsole:
self.exceptionHandler()
else:
raise
@ -431,19 +432,18 @@ class AppRunner(DirectObject):
if 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
# will properly get ignored by ShowBase.
interactiveConsole = self.interactiveConsole
self.interactiveConsole = False
self.initialAppImport = True
__import__(moduleName)
main = sys.modules[moduleName]
if hasattr(main, 'main') and callable(main.main):
main.main(self)
# Now restore this flag.
self.interactiveConsole = interactiveConsole
# Now clear this flag.
self.initialAppImport = False
if self.interactiveConsole:
# 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.task.TaskManagerGlobal import taskMgr
from direct.p3d.PackageInfo import PackageInfo
from pandac.PandaModules import TPLow
class PackageInstaller(DirectObject):
@ -145,7 +146,8 @@ class PackageInstaller(DirectObject):
# If the task chain hasn't yet been set up, create the
# default parameters now.
if not taskMgr.hasTaskChain(self.taskChain):
taskMgr.setupTaskChain(self.taskChain, numThreads = 1)
taskMgr.setupTaskChain(self.taskChain, numThreads = 1,
threadPriority = TPLow)
self.callbackLock = Lock()
self.calledDownloadStarted = False

View File

@ -2473,7 +2473,8 @@ class ShowBase(DirectObject.DirectObject):
# p3d file. When we *are* within a p3d file, the Panda
# runtime has to be responsible for running the main loop, so
# 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()