[Python-Dev] second opinion for proposed fix for bug #754449
Brett C.
bac at OCF.Berkeley.EDU
Wed Mar 3 17:32:18 EST 2004
Guido van Rossum wrote:
<SNIP>
>>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.start_new_thread(). 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