Browse Source

allow better console handling; download is low-pri thread

David Rose 16 years ago
parent
commit
f3e620677e

+ 6 - 6
direct/src/p3d/AppRunner.py

@@ -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.

+ 3 - 1
direct/src/p3d/PackageInstaller.py

@@ -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

+ 2 - 1
direct/src/showbase/ShowBase.py

@@ -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()