Potential patch for Issues like #3013 and #3017

This commit is contained in:
Miroslav Stampar
2018-04-01 12:45:47 +02:00
parent 2cc6214227
commit 4147f44e63
12 changed files with 53 additions and 12 deletions

View File

@@ -7,6 +7,8 @@ See the file 'LICENSE' for copying permission
import hashlib
from lib.core.threads import getCurrentThreadData
def cachedmethod(f, cache={}):
"""
Method with a cached content
@@ -22,3 +24,18 @@ def cachedmethod(f, cache={}):
return cache[key]
return _
def stackedmethod(f):
def _(*args, **kwargs):
threadData = getCurrentThreadData()
originalLevel = len(threadData.valueStack)
try:
result = f(*args, **kwargs)
finally:
if len(threadData.valueStack) > originalLevel:
threadData.valueStack = threadData.valueStack[:originalLevel]
return result
return _