title: Pyautogui multithreading doesnt work?
body: <p>This code works perfectly on the first run.</p>
  
  <pre><code>import time as t
  import pyautogui as p
  import threading
  
  def skincare1():
      p.alert("skincare level 1",'skincare 1')
      t.sleep(0.3)
      p.alert("skincare level 2",'skincare 2')
  
  print('start')
  
  threadem=threading.Thread(target=skincare1)
  threadem.start()
  
  print('end')
  </code></pre>
  
  <p>But when I run it again, it prints out both 'start' and 'end', and after a couple of seconds:</p>
  
  <pre><code>An error ocurred while starting the kernel
  Tcl_AsyncDelete: async handler deleted by the wrong thread
  </code></pre>
  
  <p>If I restart kernel it works fine for the first time again, but crashes on the second. 
  Any idea why?</p>
  
  <p>Edit:<br>
  If I take out the sleep part, it still runs good for the first time, but gives the same error on all further runs. But if I put in something really simple, like 'print ('middle part')' with sleep, it runs good always. So somehow this is caused by pyautogui.</p>
  
  <pre><code>import time as t
  import pyautogui as p
  import threading
  
  def skincare1():
      p.alert("skincare level 1",'skincare 1')
  
  print('start')
  
  threadem=threading.Thread(target=skincare1)
  threadem.start()
  
  print('end')
  </code></pre>