[1.18][PATCH] Backport methodpool changes from master
From: Denys Dmytriyenko <[email protected]>
The patch to retire methodpool helps fix intermittent parsing issue in Dylan:
http://thread.gmane.org/gmane.comp.handhelds.openembedded.core/42786
Richard Purdie (1):
methodpool: Retire it, remove global method scope
lib/bb/cooker.py | 2 ++ lib/bb/methodpool.py | 43 -------------------------------------- lib/bb/parse/ast.py | 8 +++---- lib/bb/parse/parse_py/BBHandler.py | 4 ---- 4 files changed, 5 insertions(+), 52 deletions(-)
Signature · 1 line
1.8.3.2
[1.18][PATCH] methodpool: Retire it, remove global method scope
From: Richard Purdie <[email protected]>
Having a global method scope confuses users and with the introduction of parallel parsing, its not even possible to correctly detect conflicting functions. Rather than try and fix that, its simpler to retire the global method scope and restrict functions to those locations they're defined within. This is more what users actually expect too.
If we remove the global function scope, the need for methodpool is reduced to the point we may as well retire it. There is some small loss of caching of parsed functions but timing measurements so the impact to be neglibile in the overall parsing time.
--- lib/bb/cooker.py | 2 ++ lib/bb/methodpool.py | 43 -------------------------------------- lib/bb/parse/ast.py | 8 +++---- lib/bb/parse/parse_py/BBHandler.py | 4 ---- 4 files changed, 5 insertions(+), 52 deletions(-)
lib/bb/cooker.py +2 -0
@@ -1606,6 +1606,7 @@ class Parser(multiprocessing.Process): self.quit = quit self.init = init multiprocessing.Process.__init__(self) + self.context = bb.utils._context.copy() def run(self): if self.init:
@@ -1640,6 +1641,7 @@ class Parser(multiprocessing.Process): def parse(self, filename, appends, caches_array): try: + bb.utils._context = self.context.copy() return True, bb.cache.Cache.parse(filename, appends, self.cfg, caches_array) except Exception as exc: tb = sys.exc_info()[2]
lib/bb/methodpool.py +0 -43
53 lines not on this page · raw message
lib/bb/parse/ast.py +3 -5
@@ -148,9 +148,8 @@ class MethodNode(AstNode): text = '\n'.join(self.body) if self.func_name == "__anonymous": funcname = ("__anon_%s_%s" % (self.lineno, self.filename.translate(string.maketrans('/.+-', '____')))) - if not funcname in bb.methodpool._parsed_fns: - text = "def %s(d):\n" % (funcname) + text - bb.methodpool.insert_method(funcname, text, self.filename) + text = "def %s(d):\n" % (funcname) + text + bb.methodpool.insert_method(funcname, text, self.filename) anonfuncs = data.getVar('__BBANONFUNCS') or [] anonfuncs.append(funcname) data.setVar('__BBANONFUNCS', anonfuncs)
@@ -171,8 +170,7 @@ class PythonMethodNode(AstNode): # 'this' file. This means we will not parse methods from # bb classes twice text = '\n'.join(self.body) - if not bb.methodpool.parsed_module(self.modulename): - bb.methodpool.insert_method(self.modulename, text, self.filename) + bb.methodpool.insert_method(self.modulename, text, self.filename) data.setVarFlag(self.function, "func", 1) data.setVarFlag(self.function, "python", 1) data.setVar(self.function, text)
lib/bb/parse/parse_py/BBHandler.py +0 -4
@@ -166,10 +166,6 @@ def handle(fn, d, include): if oldfile: d.setVar("FILE", oldfile) - # we have parsed the bb class now - if ext == ".bbclass" or ext == ".inc": - bb.methodpool.set_parsed_module(base_name) - return d def feeder(lineno, s, fn, root, statements):
Signature · 1 line
1.8.3.2
Re: [1.18][PATCH] methodpool: Retire it, remove global method scope
Quoted 8 lines · Denys Dmytriyenko
From: Richard Purdie <[email protected]>
Having a global method scope confuses users and with the introduction of parallel parsing, its not even possible to correctly detect conflicting functions. Rather than try and fix that, its simpler to retire the global method scope and restrict functions to those locations they're defined within. This is more what users actually expect too.
Quoted 7 lines
If we remove the global function scope, the need for methodpool is reduced to the point we may as well retire it. There is some small loss of caching of parsed functions but timing measurements so the impact to be neglibile in the overall parsing time.
Signed-off-by Richard Purdie <[email protected]>Tested-by Denys Dmytriyenko <[email protected]>
In general I wouldn't take this (as a feature removal) however the code in question was really broken when we introduced parallel parsing. Its therefore totally broken, has been for a long time and this patch is therefore a good thing as it is a bugfix rather than feature removal.
So I've merged it.
Cheers,
Richard
Re: [1.18][PATCH] methodpool: Retire it, remove global method scope
Quoted 17 lines · Richard Purdie
Quoted 8 lines · Denys Dmytriyenko
From: Richard Purdie <[email protected]>
Having a global method scope confuses users and with the introduction of parallel parsing, its not even possible to correctly detect conflicting functions. Rather than try and fix that, its simpler to retire the global method scope and restrict functions to those locations they're defined within. This is more what users actually expect too.
Quoted 7 lines
If we remove the global function scope, the need for methodpool is reduced to the point we may as well retire it. There is some small loss of caching of parsed functions but timing measurements so the impact to be neglibile in the overall parsing time.
Signed-off-by Richard Purdie <[email protected]>Tested-by Denys Dmytriyenko <[email protected]>
Quoted 6 lines
In general I wouldn't take this (as a feature removal) however the code in question was really broken when we introduced parallel parsing. Its therefore totally broken, has been for a long time and this patch is therefore a good thing as it is a bugfix rather than feature removal.
So I've merged it.
Thanks, Richard, appreciate it.
Signature · 1 line
Denys