Don't re-release gui thread on SIGWINCH
authorJack Miller <jack@codezen.org>
Mon, 8 Aug 2016 22:55:05 +0000 (17:55 -0500)
committerJack Miller <jack@codezen.org>
Mon, 8 Aug 2016 22:55:05 +0000 (17:55 -0500)
While Python Events are obviously thread safe, they're not reentrant so
from a signal context we have to make sure that if we receive a new
signal before we finish processing the old one, we don't attempt to
set() again and deadlock.

This fixes canto-curses locking when you resize your terminal a few
hundred times a second.

canto_curses/gui.py

index 51a934d..fc6651b 100644 (file)
@@ -162,7 +162,8 @@ class CantoCursesGui(CommandHandler):
 
     def winch(self):
         self.winched = True
-        self.release_gui()
+        if not self.do_gui.is_set():
+            self.release_gui()
 
     def cmd_refresh(self):
         # Will trigger a hook on completion that will cause refresh