On Mon, May 20, 2013 at 7:46 AM, Dennis Lee Bieber <wlfr...@ix.netcom.com> wrote: > On Sun, 19 May 2013 10:38:14 +1000, Chris Angelico <ros...@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 -- http://mail.python.org/mailman/listinfo/python-list