471,355 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,355 software developers and data experts.

threading.local _threading_local problems

Jd
Hi
I have the following situation.. Have a worker thread, that does the
"work" given to it. While doing work, some of the objects use thread
local storage for storing that requires explicit close. e.g. connection
handles. These objects are long living. The worker, does not have any
direct access to the objects.

I would like to clean up thread local area explicitly so that I do not
run out of connection handles. Any ideas on how to access local storage
from the thread ? (threading.local() gives new object everytime.. I am
looking for something like singleton / global access from within the thread)

Or is there anyway to notify the object when the thread for which it
set the local storage is going away ?

This looks to me a bit like design shortcoming. or I have missed
something completely.

Thanks
/Jd

Sep 21 '07 #1
1 2523
En Fri, 21 Sep 2007 14:36:34 -0300, Jd <jd@nospam.comescribi�:
Hi
I have the following situation.. Have a worker thread, that does the
"work" given to it. While doing work, some of the objects use thread
local storage for storing that requires explicit close. e.g. connection
handles. These objects are long living. The worker, does not have any
direct access to the objects.

I would like to clean up thread local area explicitly so that I do not
run out of connection handles. Any ideas on how to access local storage
from the thread ? (threading.local() gives new object everytime.. I am
looking for something like singleton / global access from within the
thread)
Create a local() object *once*; it may be a global variable. Then assign
to its attributes from any thread. Each thread will see a different set of
attributes.
Or is there anyway to notify the object when the thread for which it
set the local storage is going away ?
Do that at the end of the thread's run method.

--
Gabriel Genellina

Sep 22 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Varun | last post: by
1 post views Thread by Steven T. Hatton | last post: by
18 posts views Thread by Frank Rizzo | last post: by
1 post views Thread by craigedmunds | last post: by
1 post views Thread by bdoyle | last post: by
1 post views Thread by usenet | last post: by
7 posts views Thread by Mike P | last post: by
126 posts views Thread by Dann Corbit | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.