Skip to content

Instantly share code, notes, and snippets.

@UNIcodeX
Created August 13, 2020 16:52
Show Gist options
  • Save UNIcodeX/a63a0417dcc2a7dd6f13e26184f7268d to your computer and use it in GitHub Desktop.
Save UNIcodeX/a63a0417dcc2a7dd6f13e26184f7268d to your computer and use it in GitHub Desktop.
Stackless threadlet global mutation
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