Can't you emulate threads in the interpreter instead of relying on an OS-specific thread implementation?
The CPython interpreter pushes at least one C stack frame for each Python stack frame. Also, extensions can call back into Python at basically any time. Therefore, a complete threads implementation requires thread support for C.
Stackless Python is a customized version
of CPython. Stackless adds support for microthreads (also called
tasklets
), which are primarily based on cooperative context
switching. Stackless also provides communication and serialization
support for tasklets.
CATEGORY: general cpython
