title: How to release the GIL for a thread in Python, using Numba?
body: <p>I want to make a program that consists of 2 parts: one is to receive data and the other is to write it to a file. I thought that it would be better if I could use 2 threads(and possibly 2 cpu cores) to do the jobs separately. I found this: <a href="https://numba.pydata.org/numba-doc/dev/user/jit.html#compilation-options" rel="nofollow noreferrer">https://numba.pydata.org/numba-doc/dev/user/jit.html#compilation-options</a> and it allows you to release the GIL. I wonder if it suits my purpose and if I could adopt it for this kind of job. This is what I tried:</p>
  
  <pre><code>import threading
  import time
  import os
  import queue
  import numba
  import numpy as np
  
  condition = threading.Condition()
  q_text = queue.Queue()
  
  #@numba.jit(nopython=True, nogil=True)
  def consumer():
      t = threading.currentThread()
  
      with condition:
          while True:
              str_test = q_text.get()
              with open('hello.txt', 'a') as f:
                  f.write(str_test)
              condition.wait()            
  
  def sender():
      with condition:
          condition.notifyAll()
  
  def add_q(arr="hi\n"):
      q_text.put(arr)
      sender()
  
  c1 = threading.Thread(name='c1', target=consumer)
  c1.start()
  
  add_q()
  </code></pre>
  
  <p>It works fine without <code>numba</code>, but when I apply it to <code>consumer</code>, it gives me an error:</p>
  
  <pre><code>Exception in thread c1:
  Traceback (most recent call last):
    File "d:\python36-32\lib\threading.py", line 916, in _bootstrap_inner
      self.run()
    File "d:\python36-32\lib\threading.py", line 864, in run
      self._target(*self._args, **self._kwargs)
    File "d:\python36-32\lib\site-packages\numba\dispatcher.py", line 368, in _compile_for_args
      raise e
    File "d:\python36-32\lib\site-packages\numba\dispatcher.py", line 325, in _compile_for_args
      return self.compile(tuple(argtypes))
    File "d:\python36-32\lib\site-packages\numba\dispatcher.py", line 653, in compile
      cres = self._compiler.compile(args, return_type)
    File "d:\python36-32\lib\site-packages\numba\dispatcher.py", line 83, in compile
      pipeline_class=self.pipeline_class)
    File "d:\python36-32\lib\site-packages\numba\compiler.py", line 873, in compile_extra
      return pipeline.compile_extra(func)
    File "d:\python36-32\lib\site-packages\numba\compiler.py", line 367, in compile_extra
      return self._compile_bytecode()
    File "d:\python36-32\lib\site-packages\numba\compiler.py", line 804, in _compile_bytecode
      return self._compile_core()
    File "d:\python36-32\lib\site-packages\numba\compiler.py", line 791, in _compile_core
      res = pm.run(self.status)
    File "d:\python36-32\lib\site-packages\numba\compiler.py", line 253, in run
      raise patched_exception
    File "d:\python36-32\lib\site-packages\numba\compiler.py", line 245, in run
      stage()
    File "d:\python36-32\lib\site-packages\numba\compiler.py", line 381, in stage_analyze_bytecode
      func_ir = translate_stage(self.func_id, self.bc)
    File "d:\python36-32\lib\site-packages\numba\compiler.py", line 937, in translate_stage
      return interp.interpret(bytecode)
    File "d:\python36-32\lib\site-packages\numba\interpreter.py", line 92, in interpret
      self.cfa.run()
    File "d:\python36-32\lib\site-packages\numba\controlflow.py", line 515, in run
      assert not inst.is_jump, inst
  AssertionError: Failed at nopython (analyzing bytecode)
  SETUP_WITH(arg=60, lineno=17)
  </code></pre>
  
  <p>There was no error if I exclude <code>condition(threading.Condion)</code> from <code>consumer</code>, so maybe it's because JIT doesn't interpret it? I'd like to know if I can adopt <code>numba</code> to this kind of purpose and how to fix this problem(if it's possible).</p>