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
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.