Skip to content

Commit 35ac162

Browse files
authored
[QC-1322] Call the BK registration within a thread. (#2626)
* Add the env var to disable the publication from Tasks to BK * [QC-1322] Call the BK registration within a thread. * remove the useless try catch * format
1 parent ce9f89e commit 35ac162

File tree

5 files changed

+13
-21
lines changed

5 files changed

+13
-21
lines changed

Framework/src/AggregatorRunner.cxx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,11 +380,7 @@ void AggregatorRunner::start(ServiceRegistryRef services)
380380
// register ourselves to the BK
381381
if (!gSystem->Getenv("O2_QC_DONT_REGISTER_IN_BK")) { // Set this variable to disable the registration
382382
ILOG(Debug, Devel) << "Registering aggregator to BookKeeping" << ENDM;
383-
try {
384-
Bookkeeping::getInstance().registerProcess(mActivity->mId, mDeviceName, AggregatorRunner::getDetectorName(mAggregators), bkp::DplProcessType::QC_AGGREGATOR, "");
385-
} catch (std::runtime_error& error) {
386-
ILOG(Warning, Devel) << "Failed registration to the BookKeeping: " << error.what() << ENDM;
387-
}
383+
Bookkeeping::getInstance().registerProcess(mActivity->mId, mDeviceName, AggregatorRunner::getDetectorName(mAggregators), bkp::DplProcessType::QC_AGGREGATOR, "");
388384
}
389385
}
390386

Framework/src/Bookkeeping.cxx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <unistd.h>
2323
#include <filesystem>
2424
#include <fstream>
25+
#include <thread>
2526

2627
using namespace o2::bkp::api;
2728

@@ -113,7 +114,14 @@ void Bookkeeping::registerProcess(int runNumber, const std::string& name, const
113114
if (!mInitialized) {
114115
return;
115116
}
116-
mClient->dplProcessExecution()->registerProcessExecution(runNumber, type, getHostName(), name, args, detector);
117+
118+
std::thread([this, runNumber, type, name, args, detector]() {
119+
try {
120+
this->mClient->dplProcessExecution()->registerProcessExecution(runNumber, type, getHostName(), name, args, detector);
121+
} catch (std::runtime_error& error) { // catch here because we are in a thread
122+
ILOG(Warning, Devel) << "Failed registration to the BookKeeping: " << error.what() << ENDM;
123+
}
124+
}).detach();
117125
}
118126

119127
std::vector<int> Bookkeeping::sendFlagsForSynchronous(uint32_t runNumber, const std::string& detectorName, const std::vector<QcFlag>& qcFlags)

Framework/src/CheckRunner.cxx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -458,11 +458,7 @@ void CheckRunner::start(ServiceRegistryRef services)
458458
// register ourselves to the BK
459459
if (!gSystem->Getenv("O2_QC_DONT_REGISTER_IN_BK")) { // Set this variable to disable the registration
460460
ILOG(Debug, Devel) << "Registering checkRunner to BookKeeping" << ENDM;
461-
try {
462-
Bookkeeping::getInstance().registerProcess(mActivity->mId, mDeviceName, mDetectorName, bkp::DplProcessType::QC_CHECKER, "");
463-
} catch (std::runtime_error& error) {
464-
ILOG(Warning, Devel) << "Failed registration to the BookKeeping: " << error.what() << ENDM;
465-
}
461+
Bookkeeping::getInstance().registerProcess(mActivity->mId, mDeviceName, mDetectorName, bkp::DplProcessType::QC_CHECKER, "");
466462
}
467463
}
468464

Framework/src/PostProcessingRunner.cxx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,7 @@ void PostProcessingRunner::start(framework::ServiceRegistryRef dplServices)
189189
// register ourselves to the BK
190190
if (!gSystem->Getenv("O2_QC_DONT_REGISTER_IN_BK")) { // Set this variable to disable the registration
191191
ILOG(Debug, Devel) << "Registering pp task to BookKeeping" << ENDM;
192-
try {
193-
Bookkeeping::getInstance().registerProcess(mActivity.mId, mRunnerConfig.taskName, mRunnerConfig.detectorName, bkp::DplProcessType::QC_POSTPROCESSING, "");
194-
} catch (std::runtime_error& error) {
195-
ILOG(Warning, Devel) << "Failed registration to the BookKeeping: " << error.what() << ENDM;
196-
}
192+
Bookkeeping::getInstance().registerProcess(mActivity.mId, mRunnerConfig.taskName, mRunnerConfig.detectorName, bkp::DplProcessType::QC_POSTPROCESSING, "");
197193
}
198194

199195
if (mTaskState == TaskState::Created || mTaskState == TaskState::Finished) {

Framework/src/TaskRunner.cxx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -437,11 +437,7 @@ void TaskRunner::registerToBookkeeping()
437437
if (!gSystem->Getenv("O2_QC_DONT_REGISTER_IN_BK")) { // Set this variable to disable the registration
438438
// register ourselves to the BK at the first cycle
439439
ILOG(Debug, Devel) << "Registering taskRunner to BookKeeping" << ENDM;
440-
try {
441-
Bookkeeping::getInstance().registerProcess(mActivity.mId, mTaskConfig.taskName, mTaskConfig.detectorName, bkp::DplProcessType::QC_TASK, "");
442-
} catch (std::runtime_error& error) {
443-
ILOG(Warning, Devel) << "Failed registration to the BookKeeping: " << error.what() << ENDM;
444-
}
440+
Bookkeeping::getInstance().registerProcess(mActivity.mId, mTaskConfig.taskName, mTaskConfig.detectorName, bkp::DplProcessType::QC_TASK, "");
445441
}
446442
}
447443

0 commit comments

Comments
 (0)