summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb
diff options
context:
space:
mode:
authorChristopher Larson <kergoth@gmail.com>2012-02-03 08:12:55 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-02-10 17:00:54 +0000
commit754847f34b1f2cfc9683b143ca9e9e6ef054037f (patch)
treef6e90272119aec4a9dc5df4f555cab7a78206387 /bitbake/lib/bb
parentd366c1890ee706870bbf6fec714fba9022a54329 (diff)
downloadpoky-754847f34b1f2cfc9683b143ca9e9e6ef054037f.tar.gz
Revert the switch to futures for now
Without it, we get random hangs on parse failure. With it, some folks have seen hangs even on successful cases. The former is clearly less problematic. This is temporary, until I can finish investigating the root causes of both issues. (Bitbake rev: db689a99beffea1a285cdfc74a58fe73f1666987) Signed-off-by: Christopher Larson <kergoth@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r--bitbake/lib/bb/cooker.py29
1 files changed, 11 insertions, 18 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 492cf6e3a2..bb09dff82f 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -32,7 +32,6 @@ import sre_constants
32import threading 32import threading
33from cStringIO import StringIO 33from cStringIO import StringIO
34from contextlib import closing 34from contextlib import closing
35from concurrent import futures
36from functools import wraps 35from functools import wraps
37from collections import defaultdict 36from collections import defaultdict
38import bb, bb.exceptions, bb.command 37import bb, bb.exceptions, bb.command
@@ -1453,16 +1452,20 @@ class CookerParser(object):
1453 self.start() 1452 self.start()
1454 1453
1455 def start(self): 1454 def start(self):
1455 def init(cfg):
1456 parse_file.cfg = cfg
1457 multiprocessing.util.Finalize(None, bb.codeparser.parser_cache_save, args=(self.cooker.configuration.data, ), exitpriority=1)
1458
1456 self.results = self.load_cached() 1459 self.results = self.load_cached()
1457 1460
1458 if self.toparse: 1461 if self.toparse:
1459 bb.event.fire(bb.event.ParseStarted(self.toparse), self.cfgdata) 1462 bb.event.fire(bb.event.ParseStarted(self.toparse), self.cfgdata)
1460 1463
1461 parse_file.cfg = self.cfgdata 1464 self.pool = multiprocessing.Pool(self.num_processes, init, [self.cfgdata])
1462 multiprocessing.util.Finalize(None, bb.codeparser.parser_cache_save, args=(self.cfgdata,), exitpriority=1) 1465 parsed = self.pool.imap(parse_file, self.willparse)
1463 self.executor = futures.ProcessPoolExecutor(max_workers=self.num_processes) 1466 self.pool.close()
1464 self.futures = dict((self.executor.submit(parse_file, task), task) for task in self.willparse) 1467
1465 self.results = itertools.chain(self.results, self.parse_gen()) 1468 self.results = itertools.chain(self.results, parsed)
1466 1469
1467 def shutdown(self, clean=True): 1470 def shutdown(self, clean=True):
1468 if not self.toparse: 1471 if not self.toparse:
@@ -1475,9 +1478,8 @@ class CookerParser(object):
1475 self.total) 1478 self.total)
1476 bb.event.fire(event, self.cfgdata) 1479 bb.event.fire(event, self.cfgdata)
1477 else: 1480 else:
1478 for future in self.futures: 1481 self.pool.terminate()
1479 future.cancel() 1482 self.pool.join()
1480 self.executor.shutdown()
1481 1483
1482 sync = threading.Thread(target=self.bb_cache.sync) 1484 sync = threading.Thread(target=self.bb_cache.sync)
1483 sync.start() 1485 sync.start()
@@ -1489,15 +1491,6 @@ class CookerParser(object):
1489 cached, infos = self.bb_cache.load(filename, appends, self.cfgdata) 1491 cached, infos = self.bb_cache.load(filename, appends, self.cfgdata)
1490 yield not cached, infos 1492 yield not cached, infos
1491 1493
1492 def parse_gen(self):
1493 for future in futures.as_completed(self.futures):
1494 task = self.futures[future]
1495 exc = future.exception()
1496 if exc:
1497 raise exc
1498 else:
1499 yield future.result()
1500
1501 def parse_next(self): 1494 def parse_next(self):
1502 try: 1495 try:
1503 parsed, result = self.results.next() 1496 parsed, result = self.results.next()