From 1974b3e692a1d817d837bd34a02d6e2971ada5a1 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 12 Jun 2016 12:04:03 +0200 Subject: [PATCH] Fix deadlock waiting for Python task to end at end of program --- panda/src/display/graphicsEngine.cxx | 3 +++ panda/src/display/graphicsEngine.h | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index 9bd325fc95..da90172088 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -638,6 +638,9 @@ remove_all_windows() { // And, hey, let's stop the vertex paging threads, if any. 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(); #ifdef DO_PSTATS diff --git a/panda/src/display/graphicsEngine.h b/panda/src/display/graphicsEngine.h index cb371076ee..122d8be359 100644 --- a/panda/src/display/graphicsEngine.h +++ b/panda/src/display/graphicsEngine.h @@ -58,7 +58,7 @@ class Texture; class EXPCL_PANDA_DISPLAY GraphicsEngine : public ReferenceCount { PUBLISHED: GraphicsEngine(Pipeline *pipeline = NULL); - ~GraphicsEngine(); + BLOCKING ~GraphicsEngine(); void set_threading_model(const GraphicsThreadingModel &threading_model); GraphicsThreadingModel get_threading_model() const; @@ -94,7 +94,7 @@ PUBLISHED: bool add_window(GraphicsOutput *window, int sort); bool remove_window(GraphicsOutput *window); - void remove_all_windows(); + BLOCKING void remove_all_windows(); void reset_all_windows(bool swapchain); bool is_empty() const;