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

Simo simo at samba.org
Fri Jan 23 13:54:23 MST 2015


On Wed, 2015-01-21 at 12:22 +0100, Petr Viktorin wrote:
> 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.

Ahh, indeed, LGTM then.
Simo.

> > 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.
> 


-- 
Simo Sorce



More information about the samba-technical mailing list