CherryPy wsgiserver does not create a new thread for each request - it uses a pool. Each of these worker threads is a subclass of threading.Thread, so they should all be accessible through threading.enumerate ().
However, if you are talking specifically about cherrypy.thread_data, this is something else: threading.local. If you use the latest version of Python, then everything that is encoded in C and you (probably rightfully) do not have end-to-end access to it with Python. If you really need it and really know what you are doing, the best way is usually to stick to additional links to such things in the global container at the same time when they are inserted into the thread_data structure, I recommend dicts with weakrefs as keys for these global containers - there are enough Python ORMs that use them for connection pools (like my own Geniusql) so you can learn how to implement them quite easily.
source share