diff options
| author | Christophe Simonis <chs@odoo.com> | 2014-10-29 18:28:07 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2014-10-29 18:28:07 +0100 |
| commit | cc4fba6089d3a65bb014d2aa33601668fca6f0bb (patch) | |
| tree | ac1e9c877529250bdd3f1ea16a2c184c7efcb969 /openerp/tools/func.py | |
| parent | 82588faa71e8da27d886ce8402841dc4985b95ff (diff) | |
[IMP] core: manage registries via an LRU.
When working with a large number of databases, the memory allocated to
registries wasn't limited, resulting to waste memory (especially in the
longpolling worker, which is not recycled).
The size of the LRU is depending on the soft limit configured for
workers.
Diffstat (limited to 'openerp/tools/func.py')
| -rw-r--r-- | openerp/tools/func.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/openerp/tools/func.py b/openerp/tools/func.py index baeae0b1465..0a36166acee 100644 --- a/openerp/tools/func.py +++ b/openerp/tools/func.py @@ -20,7 +20,7 @@ # ############################################################################## -__all__ = ['synchronized', 'lazy_property'] +__all__ = ['synchronized', 'lazy_property', 'classproperty'] from functools import wraps from inspect import getsourcefile @@ -103,4 +103,12 @@ def compose(a, b): return a(b(*args, **kwargs)) return wrapper + +class _ClassProperty(property): + def __get__(self, cls, owner): + return self.fget.__get__(None, owner)() + +def classproperty(func): + return _ClassProperty(classmethod(func)) + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
