How such code executes in parallel despite GIL?
<p>It's all about Python2.7</p>

<p>I have next question:</p>

<pre><code>from futures import ThreadPoolExecutor

def test():

    while True:

        i = 4


executor = ThreadPoolExecutor(max_workers=2)

executor.submit(test)

executor.submit(test)
</code></pre>

<p>So when I run such code on dualcore machine, I get both of cores get busy
Why does it happens, shouldn't they execute using just half of resourses, because of GIL?
I think they use some system calls and thats why executes in parallel,
but I can't understand which part of code executes on system core.</p>

<p>here is disassabmled:</p>

<pre><code>dis.dis(main)
Disassembly of test:
2         0 SETUP_LOOP              16 (to 19)
    &gt;&gt;    3 LOAD_GLOBAL              0 (True)
          6 POP_JUMP_IF_FALSE       18

3         9 LOAD_CONST               1 (4)
         12 STORE_FAST               0 (i)
         15 JUMP_ABSOLUTE            3
    &gt;&gt;   18 POP_BLOCK           
    &gt;&gt;   19 LOAD_CONST               0 (None)
         22 RETURN_VALUE        
</code></pre>

<p>Also should be noted, that when I run ths code, I can't stop program by typing Ctr+C.</p>

<p>I think its happend because when I have 2 cores, and 3 threads (1 main and 2 threadpool)
After typing Ctr+C interpreter execute check after each tick and though ThreadPool threads are cpu bound and have low priority main thread can't accuire GIL because on another core on of ThreadPool thread catch GIL faster</p>

<p>But in my understanding, sometime main thread should aquire GIL and stop program, but it not happend during 5 min.</p>

<p>Whats going wrong?</p>