Please help with Threading

Chris Angelico rosuav at gmail.com
Sun May 19 17:52:23 EDT 2013


On Mon, May 20, 2013 at 7:46 AM, Dennis Lee Bieber
<wlfraed at ix.netcom.com> wrote:
> On Sun, 19 May 2013 10:38:14 +1000, Chris Angelico <rosuav at gmail.com>
> declaimed the following in gmane.comp.python.general:
>> With interpreted code eg in CPython, it's easy to implement preemption
>> in the interpreter. I don't know how it's actually done, but one easy
>> implementation would be "every N bytecode instructions, context
>> switch". It's still done at a lower level than user code (N bytecode
>
>         Which IS how the common Python interpreter does it -- barring the
> thread making some system call that triggers a preemption ahead of time
> (even time.sleep(0.0) triggers scheduling). Forget if the default is 20
> or 100 byte-code instructions -- as I recall, it DID change a few
> versions back.

Incidentally, is the context-switch check the same as the check for
interrupt signal raising KeyboardInterrupt? ISTR that was another
"every N instructions" check.

ChrisA



More information about the Python-list mailing list