diff options
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r-- | bitbake/lib/bb/cooker.py | 29 |
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 | |||
32 | import threading | 32 | import threading |
33 | from cStringIO import StringIO | 33 | from cStringIO import StringIO |
34 | from contextlib import closing | 34 | from contextlib import closing |
35 | from concurrent import futures | ||
36 | from functools import wraps | 35 | from functools import wraps |
37 | from collections import defaultdict | 36 | from collections import defaultdict |
38 | import bb, bb.exceptions, bb.command | 37 | import 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() |