Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Stackless hard switching with libteatet #279

Draft
wants to merge 37 commits into
base: 2.7-slp
Choose a base branch
from

Conversation

akruis
Copy link

@akruis akruis commented Jun 26, 2021

This is the historical patch for issue #10 from Kristján Valur Jónsson.

I converted this patch from a backup of the original mercurial repository available from https://bitbucket-archive.softwareheritage.org/projects/kr/krisvale/stackless-tealet.html.

The main tealet (the one calling in to python) must be suspended and the top
level tasklet evaluation loop run in a worker, because soft switching may
have the main tasklet run in an arbitrary tealet when it exits.  It then
needs to switch back to the 'main' tealet.  The only way to do this is
to have the 'main' tealet in a known state.

In the old system, it was possible to switch back to a known state of the
main stack, creating a duplicate on the fly.  Tealets are more strict because
a tealet are more like threads:  each can only run a function, not
extend back from its invocation point.
This is safe and recommended, structs have their own namespace and their
names don't clash with typedefs.
tealet to return to.  This also removes then need to tweak it
in the test_outside function.
re-implement stackless.uncollectable.
The platf/ files are still present in the repo.
We now just call a callback for the initial stub.  There is no need
to mess with cframes and such stuff.
This is a lot of legacy, it should all work through tealets now.
soft-swiching of the main tasklet, and the consequence of the main
tasklet being executed on a different stack when it exits, it is much
simpler to simply force hard switching for the main tasklet.  This
means that the main tasklet always runs on the stack provided by
the caller into the python library, including whatever stack
exception handlers they provided.
This removes the need to have the main tealet suspended while stackless
runs.
Unittest test_thread are broken here and need fixing.
@kristjanvalur
Copy link
Collaborator

Thanks, this is great for historical reasons :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants