From d86f05b35b3c47fd5bc4239ad2b31f6108f40abb Mon Sep 17 00:00:00 2001 From: Laurent Bachelier Date: Fri, 8 Mar 2019 17:55:36 +0100 Subject: [PATCH] config: Only create decorator as needed, more parameters This is mostly to avoid making the object unpicklable. Also it should be a bit faster. --- weboob/tools/config/extra.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/weboob/tools/config/extra.py b/weboob/tools/config/extra.py index 72a1597d20..4020bae0e9 100644 --- a/weboob/tools/config/extra.py +++ b/weboob/tools/config/extra.py @@ -96,12 +96,16 @@ class TimeBufferConfig(object): """ saved_since_seconds = None - def __init__(self, path, saved_since_seconds=None, *args, **kwargs): + def __init__(self, path, saved_since_seconds=None, last_run=True, logger=None, *args, **kwargs): super(TimeBufferConfig, self).__init__(path, *args, **kwargs) if saved_since_seconds: self.saved_since_seconds = saved_since_seconds + if self.saved_since_seconds: + self.save = time_buffer(since_seconds=self.saved_since_seconds, last_run=last_run, logger=logger)(self.save) - self.save = time_buffer(since_seconds=self.saved_since_seconds)(self.save) + def save(self, *args, **kwargs): + kwargs.pop('since_seconds', None) + super(TimeBufferConfig, self).save(*args, **kwargs) def force_save(self): self.save(since_seconds=False) -- GitLab