memoize renvoie un deepcopy
300f13b2
introduit une clé 'whoami' dans un dico, et l'efface
de temps en temps à coup de pop. Sauf qu'il s'agit toujours du même
dictionnaire (mémoisation oblige), on règle le problème en
copyant la structure à chaque appel.
This commit is contained in:
parent
8e39c55008
commit
114d97aa4a
1 changed files with 2 additions and 1 deletions
|
@ -23,6 +23,7 @@ import random
|
||||||
import string
|
import string
|
||||||
import time
|
import time
|
||||||
import datetime
|
import datetime
|
||||||
|
import copy
|
||||||
|
|
||||||
# Import de la config
|
# Import de la config
|
||||||
envvar = "CRANSPASSWORDS_CLIENT_CONFIG_DIR"
|
envvar = "CRANSPASSWORDS_CLIENT_CONFIG_DIR"
|
||||||
|
@ -238,7 +239,7 @@ class simple_memoize(object):
|
||||||
mais il faudra s'en préoccuper si un jour on veut changer le comportement."""
|
mais il faudra s'en préoccuper si un jour on veut changer le comportement."""
|
||||||
if self.val == None:
|
if self.val == None:
|
||||||
self.val = self.f(*args, **kwargs)
|
self.val = self.f(*args, **kwargs)
|
||||||
return self.val
|
return copy.deepcopy(self.val)
|
||||||
|
|
||||||
|
|
||||||
######
|
######
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue