title: PySerial: Open port takes too long
body: <p>I'm communicating from my PC to a Nucleo-Board via UART. For that I'm using <a href="https://pyserial.readthedocs.io/en/latest/" rel="nofollow noreferrer">PySerial</a>, a FTDI-USB-Cable for data connection and a USB-Cable for power. <code>open()</code> works fine, except when I remove the power from my Nucleo-Board. Then <code>open()</code> needs way too long (2-4 seconds). &quot;Okay, then just don't remove the power from the Nucleo-Board&quot;. Yeah true, but I want to handle this case -&gt; it will open an error window. The only problem is, that it takes 2-4 seconds to open that window because <code>open()</code> takes too long.</p>
  <p>A problem could be that the UART cable is still connected which makes the COM-Port available which won't raise an error when using <code>open()</code>. But I don't know why it takes so long. It doesn't communicate with the Board yet, it just opens the COM Port, right? If it already communicates, then it could be a problem, because the Board does not respond because it's not connected to the power.</p>
  <p>My code to check how long <code>open()</code> takes:</p>
  <pre class="lang-py prettyprint-override"><code>start_serialwrite1 = time.perf_counter()
  
  try:
      self.ser.open()
  
      end_serialwrite1 = time.perf_counter()
      print(f&quot;time serialwrite1: {end_serialwrite1-start_serialwrite1}&quot;)
  except serial.SerialException as e:
      print(&quot;ERROR&quot;)
      self.ser.close()
  </code></pre>
  <p>Output, when I unplug the power cable:</p>
  <pre><code>time serialwrite1: 3.3720932
  </code></pre>