title: Tcl_AsyncDelete with pynput and pyautogui
body: <p>In a simplified version of the code:</p>
  
  <pre class="lang-py prettyprint-override"><code>from pynput import keyboard
  import time
  import pyautogui
  
  
  class Test:
      def __init__(self):
          self.paused = False
  
      def on_activate(self):
          if self.paused:
              pyautogui.alert(text='was paused', title='title', button='button')
              self.paused = False
          elif self.paused is False:
              pyautogui.alert(text='was not paused', title='title', button='button')
              self.paused = True
  
  
  test = Test()
  pyautogui.alert(text='test', title='title', button='button')
  hotkey = keyboard.GlobalHotKeys({
      '&lt;ctrl&gt;+a': test.on_activate
  })
  hotkey.start()
  
  while True:
      time.sleep(1)
  </code></pre>
  
  <p>I will get the error <code>Tcl_AsyncDelete: async handler deleted by the wrong thread</code>.</p>
  
  <p>Now I understand that this comes from issues handling threading, or rather the lack of said handling. I noticed that if the code runs without the alert() below the class declaration; there is never any such error.</p>
  
  <p>I believe I understand that this comes from pynput working on another thread than the first pyautogui call was made; however since I no longer have a use for for alert boxes there is there a way to "properly close" it in that thread and operate it on the other?</p>
  
  <p>I am at a slight loss and any input or help would be greatly appreciated.</p>