Skip to contentSkip to conversation

cooker: replace use of map() with list comprehension

PATCH In review Elliot Smith 1 participant 2 messages Jun 14, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cooker: replace use of map() with list comprehension

In Python 3, map() returns an interator rather than a list. This causes problems for Toaster, which is unable to process the BuildInit event when it is received. This causes the build to "hang" from Toaster's point of view.

Replace the call to map() with a list comprehension instead, which returns the list which Toaster is expecting and enables builds to register.

---
 bitbake/lib/bb/cooker.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bitbake/lib/bb/cooker.py +1 -1
index 0a0b362..204709c 100644
@@ -1367,7 +1367,7 @@ class BBCooker:
 
         # build a list of target:task strings in format
         # ['zlib:do_build', 'mpfr-native:do_build', ...]
-        packages = map(lambda target: "%s:do_%s" % (target, task), targets)
+        packages = ["%s:do_%s" % (target, task) for target in targets]
         bb.event.fire(bb.event.BuildInit(packages), self.expanded_data)
 
         def buildTargetsIdle(server, rq, abort):
Signature · 1 line
2.7.4
#1 lore raw

Please ignore, as the patch this is based on has been rejected from bitbake.

Elliot

Quoted 43 lines · Elliot Smith

In Python 3, map() returns an interator rather than a list. This causes problems for Toaster, which is unable to process the BuildInit event when it is received. This causes the build to "hang" from Toaster's point of view.

Replace the call to map() with a list comprehension instead, which returns the list which Toaster is expecting and enables builds to register.

---
 bitbake/lib/bb/cooker.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
bitbake/lib/bb/cooker.py +1 -1
index 0a0b362..204709c 100644
@@ -1367,7 +1367,7 @@ class BBCooker:
 
         # build a list of target:task strings in format
         # ['zlib:do_build', 'mpfr-native:do_build', ...]
-        packages = map(lambda target: "%s:do_%s" % (target, task),
 targets)
+        packages = ["%s:do_%s" % (target, task) for target in targets]
         bb.event.fire(bb.event.BuildInit(packages), self.expanded_data)
 

def buildTargetsIdle(server, rq, abort):
--
2.7.4

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

Signature · 3 lines
Elliot Smith
Software Engineer
Intel Open Source Technology Centre