[PATCH] buildtools: Use separate storage for each function in runonce

Petr Viktorin pviktori at redhat.com
Wed Jan 21 04:22:41 MST 2015


On 01/20/2015 03:48 PM, Simo wrote:
> On Tue, 2015-01-20 at 14:01 +0100, Petr Viktorin wrote:
>> On 01/16/2015 06:55 PM, Petr Viktorin wrote:
>>> Hello,
>>> I ran across this curiosity while trying to wrap my head around the
>>> build system:
>>>
>>>       @runonce
>>>       def add_one(x):
>>>           return x + 1
>>>
>>>       @runonce
>>>       def sub_one(x):
>>>           return x - 1
>>>
>>>       add_one(1) # returns 2
>>>       sub_one(1) # also returns 2!
>>>
>>>
>>> Fix attached.
>>>
>>
>> Once again, with the sign-off line. Sorry for the noise.
>>
>
> Doesn't this patch also remove the intended functionality of running the
> same function only once ?

No. With the patch, a new dict for storage (and a new `runonce_wrapper` 
function) is made every time the decorator runs – once for each 
`@runonce` line.

> It looks to me that the proper fix would be to add the function name to
> args ? Am I completely off track ?

That approach would also work, yes.

-- 
Petr Viktorin



More information about the samba-technical mailing list