We have a Pylons WSGI app that lazily creates connections to a resource. That is to say, it uses a threading.local instance to see if a connection exists for the thread and creates one if it does not.
This solves the trick of o开发者_运维百科pening connections, but how can I close my connections properly when the thread exits? I can't find any information about how to be alerted when a thread is being terminated.
精彩评论