3

I'm starting with Stackless Python so it's a whole new amazing world for me. I usually use regular threads, and they normally have Thread-local storage (TLS), which is a very useful feature when you need NOT share memory with other threads.

So, I'm wondering if Stackless Python has something similar: A way to store local memory (a python object) for a given tasklet. Is that possible?

Thanks in advance. -f

1 Answer 1

1

Solution1: The TLS can be simulated in stackless/greenlet using the current tasklet object, retrieved by the call of stackless.getcurrent(), to store additional data.

Solution2: If the tasklet didn't support to add extra fields, than you can have a global WeakKeyDictionary instance that will have as weakref key the tasklet, and value represents your TLS.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.