[Python-Dev] second opinion for proposed fix for bug #754449 (original) (raw)

Brett C. bac at OCF.Berkeley.EDU
Wed Mar 3 17:32:18 EST 2004


Guido van Rossum wrote:

>>_Basically the exception stems from a call to threading.currentThread in_ >>_the Condition class (which is just Condition) which, according to the_ >>_comment along with the call, is just for its side-effect. Well, I_ >>_looked and I can't find the need for the side-effect. I took out the_ >>_code and ran the regression tests and nothing failed because of it._ >>>>_Since the code says the call is for the explicit side-effect I just_ >>_wanted another pair of eyes to quickly scan the code in threading.py and_ >>_either agree with me or tell me I am blind and point out where the_ >>_side-effect is needed for Condition instances. The offending_ >>_currentThread calls can be found on lines 196 and 238 (can also just_ >>_search for "side-effect" to find them)._ >>> _This is my code. It was long ago. I think the intended side effect_ > _is creating a dummy thread *IF* the calling thread was not created by_ > _the threading module but by thread.startnewthread(). The current_ > _thread in turn is only relevant when the Condition's lock is an RLock._ > _But the only thing that is ever done with that is comparing it with_ > _the outcome of another call to currentThread()._

Right. And RLock makes the call itself so it seems RLock on its own will trigger the side-effect when it needs it.

So I THINK that the side effect isn't particularly needed.

OK. That's good enough for me.

(But the threading module references other globals, so I'm not sure that ripping out the currentThread() calls is really enough, except in this particular app's case.)

Yeah. To force this problem (couldn't trigger it) I set everything to None in threading and then tried this. It triggered the right error, but the function registered with atexit also threw a fit. But that is a forced error since atexit will do its thing before teardown, right?

Regardless, I will try to go through the code and see if there are any other points during the shutdown the reference a global and see if there is a way to solve it cleanly. Otherwise I guess people just need to shutdown there threading instances properly.

-Brett



More information about the Python-Dev mailing list