hydra-queue-runner: Handle exceptions in the dispatcher thread
E.g. "resource unavailable" when creating new threads.
This commit is contained in:
parent
7863d2e1da
commit
de9d7bcf25
|
@ -32,28 +32,36 @@ void State::makeRunnable(Step::ptr step)
|
||||||
void State::dispatcher()
|
void State::dispatcher()
|
||||||
{
|
{
|
||||||
while (true) {
|
while (true) {
|
||||||
printMsg(lvlDebug, "dispatcher woken up");
|
|
||||||
nrDispatcherWakeups++;
|
|
||||||
|
|
||||||
auto now1 = std::chrono::steady_clock::now();
|
try {
|
||||||
|
printMsg(lvlDebug, "dispatcher woken up");
|
||||||
|
nrDispatcherWakeups++;
|
||||||
|
|
||||||
auto sleepUntil = doDispatch();
|
auto now1 = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
auto now2 = std::chrono::steady_clock::now();
|
auto sleepUntil = doDispatch();
|
||||||
|
|
||||||
dispatchTimeMs += std::chrono::duration_cast<std::chrono::milliseconds>(now2 - now1).count();
|
auto now2 = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
/* Sleep until we're woken up (either because a runnable build
|
dispatchTimeMs += std::chrono::duration_cast<std::chrono::milliseconds>(now2 - now1).count();
|
||||||
is added, or because a build finishes). */
|
|
||||||
{
|
/* Sleep until we're woken up (either because a runnable build
|
||||||
auto dispatcherWakeup_(dispatcherWakeup.lock());
|
is added, or because a build finishes). */
|
||||||
if (!*dispatcherWakeup_) {
|
{
|
||||||
printMsg(lvlDebug, format("dispatcher sleeping for %1%s") %
|
auto dispatcherWakeup_(dispatcherWakeup.lock());
|
||||||
std::chrono::duration_cast<std::chrono::seconds>(sleepUntil - std::chrono::system_clock::now()).count());
|
if (!*dispatcherWakeup_) {
|
||||||
dispatcherWakeup_.wait_until(dispatcherWakeupCV, sleepUntil);
|
printMsg(lvlDebug, format("dispatcher sleeping for %1%s") %
|
||||||
|
std::chrono::duration_cast<std::chrono::seconds>(sleepUntil - std::chrono::system_clock::now()).count());
|
||||||
|
dispatcherWakeup_.wait_until(dispatcherWakeupCV, sleepUntil);
|
||||||
|
}
|
||||||
|
*dispatcherWakeup_ = false;
|
||||||
}
|
}
|
||||||
*dispatcherWakeup_ = false;
|
|
||||||
|
} catch (std::exception & e) {
|
||||||
|
printMsg(lvlError, format("dispatcher: %1%") % e.what());
|
||||||
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printMsg(lvlError, "dispatcher exits");
|
printMsg(lvlError, "dispatcher exits");
|
||||||
|
|
Loading…
Reference in a new issue