Created
August 13, 2020 16:52
-
-
Save UNIcodeX/a63a0417dcc2a7dd6f13e26184f7268d to your computer and use it in GitHub Desktop.
Stackless threadlet global mutation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import stackless | |
| class T: | |
| metric = 0 | |
| instance_T = T | |
| def increment_T_metric(instance): | |
| instance.metric += 1 | |
| for i in range(0, 500): | |
| stackless.tasklet(increment_T_metric)(instance_T) | |
| stackless.run() | |
| print(instance_T.metric) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment