title: Different behaviour in normal and debug run in threaded Virtualbox
body: <p>I'm encountering a weird error when running the script in PyCharm's debug mode or inside a Flask app. I have narrowed down my code to the following </p>
  
  <pre><code>import virtualbox
  import threading
  
  class ThreadExecutor(threading.Thread):
      def __init__(self):
          super().__init__()
  
      def run(self):
          vbox = virtualbox.VirtualBox()
  
  
  if __name__ == '__main__':
      th = ThreadExecutor()
      th.start()
  </code></pre>
  
  <p>Running this as a module produces no errors and executes perfectly fine but in debug mode it produces the following error message</p>
  
  <pre><code>Connected to pydev debugger (build 181.5087.37)
  Exception in thread Thread-6:
  Traceback (most recent call last):
    File "C:\Program Files\Python36\lib\site-packages\vboxapi\__init__.py", line 449, in __init__
      None)
  pywintypes.com_error: (-2147221008, 'CoInitialize has not been called.', None, None)
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "C:\Program Files\Python36\lib\threading.py", line 916, in _bootstrap_inner
      self.run()
    File "C:/Users/.../dev/debug.py", line 13, in run
      vbox = virtualbox.VirtualBox()
    File "C:\Program Files\Python36\lib\site-packages\virtualbox\library_ext\vbox.py", line 22, in __init__
      manager = virtualbox.Manager()
    File "C:\Program Files\Python36\lib\site-packages\virtualbox\__init__.py", line 143, in __init__
      self.manager = vboxapi.VirtualBoxManager(mtype, mparams)
    File "C:\Program Files\Python36\lib\site-packages\vboxapi\__init__.py", line 991, in __init__
      self.platform = PlatformMSCOM(dPlatformParams)
    File "C:\Program Files\Python36\lib\site-packages\vboxapi\__init__.py", line 455, in __init__
      print("Warning: CoInitializeSecurity failed: ", oXctp);
  NameError: name 'oXctp' is not defined
  </code></pre>
  
  <p>Going into \vboxapi__init__.py we find</p>
  
  <pre><code>try:
      pythoncom.CoInitializeSecurity(None,
                                     None,
                                     None,
                                     pythoncom.RPC_C_AUTHN_LEVEL_DEFAULT,
                                     pythoncom.RPC_C_IMP_LEVEL_IMPERSONATE,
                                     None,
                                     pythoncom.EOAC_NONE,
                                     None)
  except:
      _, oXcpt, _ = sys.exc_info();
      if isinstance(oXcpt, pythoncom.com_error) and self.xcptGetStatus(oXcpt) == -2147417831: # RPC_E_TOO_LATE
          print("Warning: CoInitializeSecurity was already called");
      else:
          print("Warning: CoInitializeSecurity failed: ", oXctp);
  </code></pre>
  
  <p>What's causing this error? Does <code>sys.exc_info()</code> behave differently inside a thread inside a debugger?</p>