title: `multiprocessing.Process` imports variable differently in windows vs. linux
body: <h1>Background</h1>
  
  <p>In an effort to learn more - and to have better cross-platform building in C - I am working on a makefile equivalent compiler and debugger.  Something like an IDE, but not so much.  I don't want to get too bogged down in this part of it, but enough to explain that I would like to utilize part of the open-source project called <a href="https://gdbgui.com/" rel="nofollow noreferrer">gdbgui</a> as the debugger.</p>
  
  <p>In my ideal use, I will kick off <code>gdbgui</code> in its own <code>Process</code> so that I can kill it from the main process.  Fortunately for me, <code>gdbgui</code> is written in python, so it should be relatively simple to simply replace the <code>main()</code> with my own custom implementation.</p>
  
  <h1>Implementation</h1>
  
  <p>I looked into the <code>gdbgui</code> source and found the relevant bits of <code>main()</code> that give me access to the functional sections within <a href="https://github.com/cs01/gdbgui/blob/master/gdbgui/backend.py" rel="nofollow noreferrer"><code>backend.py</code></a>:</p>
  
  <ul>
  <li><code>app</code> is an instance of <code>Flask()</code></li>
  <li><code>setup_backend</code> is apparently the function that kicks off the flask server with some bits of configuration.</li>
  </ul>
  
  <p>My intent was to do the same thing that <code>main()</code> is doing, without all of the command line parsing.  More specifically, customize the <code>app</code> and run <code>setup_backend()</code>.  I have removed some code for the sake of brevity (stopping the process, for instance), but this is the functional bit:</p>
  
  <pre><code>from multiprocessing import Process
  
  from gdbgui.backend import app as _app
  from gdbgui.backend import setup_backend as _setup_backend
  
  def start_stop_gdb():
      _app.config['rr'] = False
      _app.config['gdb_path'] = 'gdb'
      _app.config['show_gdbgui_upgrades'] = False
      _app.config['initial_binary_and_args'] = ['./debug.elf']
  
      self.process = Process(
          target=_setup_backend,
          kwargs={
              'serve': True,
              'port': 5000,
              'open_browser': True
          }
      )
      self.process.start()
  </code></pre>
  
  <p>This actually works perfectly in linux, which is where I first tried it.  My goal is to have a very portable implementation, so I would like to have it work the same way in windows as well.</p>
  
  <h1>The Problem</h1>
  
  <p>When I run in Windows, I get a <code>KeyError</code> which says that <code>app</code> doesn't have the <code>rr</code> key, which was specifically assigned in the above code segment.</p>
  
  <p>If I run <code>_setup_backend()</code> directly without <code>multiprocessing.Process</code>, then it works fine in Windows and in Linux, but my primary thread freezes until the program is exited <em>and</em> the primary program cannot halt the debugging process.</p>
  
  <p>To be clear, the following code segment works in Windows, but blocks the main thread:</p>
  
  <pre><code>def start_stop_gdb():
      _app.config['rr'] = False
      _app.config['gdb_path'] = 'gdb'
      _app.config['show_gdbgui_upgrades'] = False
      _app.config['initial_binary_and_args'] = ['./debug.elf']
  
      _setup_backend(
          serve=True, port=5000, 'open_browser'=True
      )
  </code></pre>
  
  <p>In short, it appears that, in linux, the instance of <code>app</code> is being updated as desired, but in windows a separate instance of <code>app</code> is being used.</p>
  
  <p>Thoughts?</p>