Skip to content

Commit

Permalink
added engine property 'timeout_after_sec'
Browse files Browse the repository at this point in the history
  • Loading branch information
joern274 committed Sep 10, 2024
1 parent 8a60288 commit 44a2a45
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ namespace hal
[this](int exitCode, QProcess::ExitStatus exitStatus){ this->handleFinished(exitCode,exitStatus); });

(*mProcessLog) << logCommand;
mProcessLog->flush();

mProcess->start(prog, args);

Expand All @@ -247,13 +248,27 @@ namespace hal

if (qApp)
{
if (exec()) // event loop ended with non-zero value
return false;
// entering event loop
if (exec())
return false; // event loop ended with non-zero value
}
else
{
int msecs = 30000;
QString timeoutAfterSec = QString::fromStdString(mEngine->get_engine_property("timeout_after_sec"));
if (!timeoutAfterSec.isEmpty())
{
bool ok;
msecs = timeoutAfterSec.toInt(&ok) * 1000;
if (!ok || msecs <= 0) msecs = -1;
}
log_warning("simulation_plugin", "No QApplication running, event loop not entered, will poll for process to finish.");
if (!mProcess->waitForFinished(-1)) return false;
if (!mProcess->waitForFinished(msecs))
{
(*mProcessLog) << "<p><font color=\"#ff4040\">Process timeout after 30 sec.</font></p>\n";
mProcessLog->flush();
return false;
}
handleReadyReadStandardError();
handleReadyReadStandardOutput();
}
Expand Down

0 comments on commit 44a2a45

Please sign in to comment.