<p dir="ltr"><br>
On Mar 17, 2014 12:53 PM, "Jurko Gospodnetić" <<a href="mailto:jurko.gospodnetic@pke.hr">jurko.gospodnetic@pke.hr</a>> wrote:<br>
><br>
>   Hi.<br>
><br>
><br>
> On 17.3.2014. 19:03, Ian Kelly wrote:<br>
>><br>
>> So yes, despite the lack of true concurrency, a thread can continue to<br>
>> run after its _stop has been called.<br>
><br>
><br>
>   Actually 'true' or 'false' concurrency does not matter here.<br>
><br>
>   CPython supports multiple threads and implements them using underlying native OS threads. The fact that it has an internal mutex (GIL) preventing it from executing/interpreting Python code at the same time in multiple threads (most of the time) does not come into play.. When one thread exits its GIL protected section (e.g. finishes processing one bytecode instruction and is about to go on to processing the next one), another thread may pick up the GIL and do some of its work, e.g. print out some output.</p>

<p dir="ltr">Yes, and whenever a thread acquires the GIL it *could* check whether its _stop flag has been set before it starts executing any Python code. Apparently though it does not, perhaps for performance reasons.</p>