Browse Source

Fix deadlock waiting for Python task to end at end of program

rdb 9 years ago
parent
commit
1974b3e692
2 changed files with 5 additions and 2 deletions
  1. 3 0
      panda/src/display/graphicsEngine.cxx
  2. 2 2
      panda/src/display/graphicsEngine.h

+ 3 - 0
panda/src/display/graphicsEngine.cxx

@@ -638,6 +638,9 @@ remove_all_windows() {
   // And, hey, let's stop the vertex paging threads, if any.
   // And, hey, let's stop the vertex paging threads, if any.
   VertexDataPage::stop_threads();
   VertexDataPage::stop_threads();
 
 
+  // Stopping the tasks means we have to release the Python GIL while
+  // this method runs (hence it is marked BLOCKING), so that any
+  // Python tasks on other threads won't deadlock grabbing the GIL.
   AsyncTaskManager::get_global_ptr()->stop_threads();
   AsyncTaskManager::get_global_ptr()->stop_threads();
 
 
 #ifdef DO_PSTATS
 #ifdef DO_PSTATS

+ 2 - 2
panda/src/display/graphicsEngine.h

@@ -58,7 +58,7 @@ class Texture;
 class EXPCL_PANDA_DISPLAY GraphicsEngine : public ReferenceCount {
 class EXPCL_PANDA_DISPLAY GraphicsEngine : public ReferenceCount {
 PUBLISHED:
 PUBLISHED:
   GraphicsEngine(Pipeline *pipeline = NULL);
   GraphicsEngine(Pipeline *pipeline = NULL);
-  ~GraphicsEngine();
+  BLOCKING ~GraphicsEngine();
 
 
   void set_threading_model(const GraphicsThreadingModel &threading_model);
   void set_threading_model(const GraphicsThreadingModel &threading_model);
   GraphicsThreadingModel get_threading_model() const;
   GraphicsThreadingModel get_threading_model() const;
@@ -94,7 +94,7 @@ PUBLISHED:
 
 
   bool add_window(GraphicsOutput *window, int sort);
   bool add_window(GraphicsOutput *window, int sort);
   bool remove_window(GraphicsOutput *window);
   bool remove_window(GraphicsOutput *window);
-  void remove_all_windows();
+  BLOCKING void remove_all_windows();
   void reset_all_windows(bool swapchain);
   void reset_all_windows(bool swapchain);
 
 
   bool is_empty() const;
   bool is_empty() const;