title: Python Ctypes & Threading
body: <p>To put this into context, I'm creating a wrapper for a C DLL - Fairly convoluted use case but please stick with me!</p>
  
  <p>During the init of my wrapper class, I create aliases to my C DLL's functions so my class can access them easily later on. An additional task I do is pass a callback to a function within my class to my DLL, which is saved in a static variable and used later.</p>
  
  <p>Finally, I spawn another thread which repeatedly calls a function within my DLL which does some work and at various points within its execution, needs to call back into the Python program using the callback assigned in the init phase of my class.</p>
  
  <p>When the callback is invoked in this fashion I receive the following:</p>
  
  <pre><code>WindowsError: exception: access violation reading 0x00000001
  </code></pre>
  
  <p>I suspect this is to do with threading because when I test the callback in the same thread to which I assigned it, the DLL can successfully invoke it and all my arguments get passed across to Python. Is there some protection being enforced over my variable within my DLL which I'm using to persist my callback?</p>