title: Serial Port WindowsError(5, 'Access is denied.') with multiprocessing
body: <p>I have a python program using serial port to connect with Arduino. I want to plot some data in real time without slowing down the execution, so I try multiprocessing. However, I got the error</p>
  
  <pre><code>    serial.serialutil.SerialException: could not open port 'COM6': WindowsError(5, 'Access is denied.') # COM6 is the port connected to Arduino
  </code></pre>
  
  <p>Surprisingly, the connection between Arduino is still alive while the function in multiprocessing is not running. My code is as follows,</p>
  
  <pre><code>class ArduinoThread(threading.Thread):
      def __init__(self, portnum):
          threading.Thread.__init__(self)
          self.setName("Arduino")
          self.Arduino = serial.Serial(port="COM"+str(portnum), baudrate=19200)
      def run(self):
          # some function
  
  
  def MyPlot_realtime(DATA):
      while True:
          data = DATA.get(False)
          plt.plot(data)
  
  
  UNO = ArduinoThread(6)
  UNO.start()
  
  plt.ion()
  pltQ = multiprocessing.Queue()
  pltP = multiprocessing.Process(target=MyPlot_realtime, args=(pltQ,))
  pltP.start()
  
  while True:
      # some calculation on data
      UNO.update(data)
  
      if pltQ.empty():
          pltQ.put(data)
  </code></pre>
  
  <p>Simply commenting the multiprocessing part the code can work well. The error pop out when there is multiprocessing but the <code>UNO.update(data)</code> is still working while <code>MyPlt_realtime</code> is not working at all.  </p>
  
  <p>(My code is quite complicated so I simplified it. I am using another serial port to connect another device. I am using Tkinter as well. Hope the problem didn't come from those part)</p>