import itertools
import logging
import multiprocessing
-import signal
import sre_constants
import threading
from cStringIO import StringIO
self.command = bb.command.Command(self)
self.state = state.initial
+ self.parser = None
+
def parseConfiguration(self):
buildname = bb.data.getVar("BUILDNAME", self.configuration.data)
bb.event.fire(bb.event.BuildStarted(buildname, [item]), self.configuration.event_data)
- # Clear locks
- bb.fetch.persistent_database_connection = {}
-
# Execute the runqueue
runlist = [[item, "do_%s" % task]]
buildlog.error("'%s' failed" % taskdata.fn_index[fnid])
failures += len(exc.args)
retval = False
+ except SystemExit as exc:
+ self.command.finishAsyncCommand()
+ return False
+
if not retval:
bb.event.fire(bb.event.BuildCompleted(buildname, item, failures), self.configuration.event_data)
self.command.finishAsyncCommand()
buildlog.error("'%s' failed" % taskdata.fn_index[fnid])
failures += len(exc.args)
retval = False
+ except SystemExit as exc:
+ self.command.finishAsyncCommand()
+ return False
+
if not retval:
bb.event.fire(bb.event.BuildCompleted(buildname, targets, failures), self.configuration.event_data)
self.command.finishAsyncCommand()
runlist.append([k, "do_%s" % task])
taskdata.add_unresolved(localdata, self.status)
- # Clear locks
- bb.fetch.persistent_database_connection = {}
-
rq = bb.runqueue.RunQueue(self, self.configuration.data, self.status, taskdata, runlist)
self.server_registration_cb(buildTargetsIdle, rq)
if self.state == state.running:
return
+ if self.state in (state.shutdown, state.stop):
+ self.parser.shutdown(clean=False)
+ sys.exit(1)
+
if self.state != state.parsing:
self.parseConfiguration ()
def start(self):
def init(cfg):
- signal.signal(signal.SIGINT, signal.SIG_IGN)
- multiprocessing.util.Finalize(None, bb.codeparser.parser_cache_save, args=(self.cooker.configuration.data, ), exitpriority=1)
parse_file.cfg = cfg
+ multiprocessing.util.Finalize(None, bb.codeparser.parser_cache_save, args=(self.cooker.configuration.data, ), exitpriority=1)
self.results = self.load_cached()
sync = threading.Thread(target=self.bb_cache.sync)
sync.start()
- atexit.register(lambda: sync.join())
+ multiprocessing.util.Finalize(None, sync.join, exitpriority=-100)
bb.codeparser.parser_cache_savemerge(self.cooker.configuration.data)
def load_cached(self):
except StopIteration:
self.shutdown()
return False
- except KeyboardInterrupt:
- self.shutdown(clean=False)
- raise
except ParsingFailure as exc:
self.shutdown(clean=False)
bb.fatal('Unable to parse %s: %s' %
self.rqdata.runq_depends[task],
self.rqdata.runq_revdeps[task])
-
class RunQueue:
def __init__(self, cooker, cfgData, dataCache, taskData, targets):
newsi = os.open(os.devnull, os.O_RDWR)
os.dup2(newsi, sys.stdin.fileno())
-
bb.data.setVar("BB_WORKERCONTEXT", "1", self.cooker.configuration.data)
+ bb.data.setVar("__RUNQUEUE_DO_NOT_USE_EXTERNALLY", self, self.cooker.configuration.data)
+ bb.data.setVar("__RUNQUEUE_DO_NOT_USE_EXTERNALLY2", fn, self.cooker.configuration.data)
+ bb.parse.siggen.set_taskdata(self.rqdata.hashes, self.rqdata.hash_deps)
the_data = bb.cache.Cache.loadDataFull(fn, self.cooker.get_file_appends(fn), self.cooker.configuration.data)
if quieterrors:
the_data.setVarFlag(taskname, "quieterrors", "1")
- bb.data.setVar("__RUNQUEUE_DO_NOT_USE_EXTERNALLY", self, self.cooker.configuration.data)
- bb.data.setVar("__RUNQUEUE_DO_NOT_USE_EXTERNALLY2", fn, self.cooker.configuration.data)
- bb.parse.siggen.set_taskdata(self.rqdata.hashes, self.rqdata.hash_deps)
for h in self.rqdata.hashes:
bb.data.setVar("BBHASH_%s" % h, self.rqdata.hashes[h], the_data)