From da87eb71e6280a01b10e50c7d69d643943a2d609 Mon Sep 17 00:00:00 2001 From: Jonathan Harris Date: Sun, 31 Jan 2016 12:44:39 +0000 Subject: [PATCH] Fix race condition on stopping. --- hotkey.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hotkey.py b/hotkey.py index 416bd51d..50c1b36c 100644 --- a/hotkey.py +++ b/hotkey.py @@ -296,10 +296,11 @@ elif platform == 'win32': self.thread.start() def unregister(self): - if self.thread: - PostThreadMessage(self.thread.ident, WM_QUIT, 0, 0) - self.thread.join() # Wait for it to unregister hotkey and quit - self.thread = None + thread = self.thread + if thread: + self.thread = None + PostThreadMessage(thread.ident, WM_QUIT, 0, 0) + thread.join() # Wait for it to unregister hotkey and quit def worker(self, keycode, modifiers):