I have implemented a python webserver. Each http request spawns a new thread. I have a requirement of caching objects in memory and since its a webserver, I want the cache t
For a thread safe object you want threading.local:
from threading import local safe = local() safe.cache = {}
You can then put and retrieve objects in safe.cache with thread safety.
safe.cache