title: Python pynput - program lags upon start
body: <p>So I've been trying to make a simple program that, upon clicking the right mouse button, makes my mouse click the left button 3 times in 0.5 second intervals. However, when I start the program and do right click, the program does what it's told to do but also starts lagging horrendously for about 25 seconds. After it's done lagging and I try to close the program, it freezes, forcing me to close it via task manager.</p>
  
  <p>The code is as follows:</p>
  
  <pre><code>import time
  from pynput.mouse import Button, Controller, Listener
  
  mouse = Controller()
  
  def on_click(x, y, button, pressed):
      if button == Button.right:
          num = 3
          while num &gt; 0:
              time.sleep(0.5)
              mouse.click(Button.left)
              num -= 1
  
  with Listener(on_click=on_click) as listener:
      listener.join()
  </code></pre>
  
  <p>Any help is greatly appreciated.</p>