Skip to content

Commit c028ffe

Browse files
committed
fix: isolate MonitoringReporter
1 parent c4e89ab commit c028ffe

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/DIRAC/Core/DISET/private/Service.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"""
2-
Service class implements the server side part of the DISET protocol
3-
There are 2 main parts in this class:
2+
Service class implements the server side part of the DISET protocol
3+
There are 2 main parts in this class:
44
5-
- All useful functions for initialization
6-
- All useful functions to handle the requests
5+
- All useful functions for initialization
6+
- All useful functions to handle the requests
77
"""
88
# pylint: skip-file
99
# __searchInitFunctions gives RuntimeError: maximum recursion depth exceeded
@@ -102,17 +102,10 @@ def initialize(self):
102102
}
103103
self.securityLogging = Operations().getValue("EnableSecurityLogging", False)
104104

105-
# Initialize Monitoring
106-
# The import needs to be here because of the CS must be initialized before importing
107-
# this class (see https://github.com/DIRACGrid/DIRAC/issues/4793)
108-
from DIRAC.MonitoringSystem.Client.MonitoringReporter import MonitoringReporter
109-
110-
self.activityMonitoringReporter = MonitoringReporter(monitoringType="ServiceMonitoring")
111-
112105
# Call static initialization function
113106
try:
114107
self._handler["class"]._rh__initializeClass(
115-
dict(self._serviceInfoDict), self._lockManager, self._msgBroker, self.activityMonitoringReporter
108+
dict(self._serviceInfoDict), self._lockManager, self._msgBroker, None
116109
)
117110
if self._handler["init"]:
118111
for initFunc in self._handler["init"]:
@@ -563,6 +556,9 @@ def _executeAction(self, trid, proposalTuple, handlerObj):
563556
retStatus = "OK"
564557
else:
565558
retStatus = "ERROR"
559+
from DIRAC.MonitoringSystem.Client.MonitoringReporter import MonitoringReporter
560+
561+
self.activityMonitoringReporter = MonitoringReporter(monitoringType="ServiceMonitoring")
566562
self.activityMonitoringReporter.addRecord(
567563
{
568564
"timestamp": int(TimeUtilities.toEpochMilliSeconds()),
@@ -592,6 +588,9 @@ def _mbReceivedMsg(self, trid, msgObj):
592588
handlerObj = result["Value"]
593589
response = handlerObj._rh_executeMessageCallback(msgObj)
594590
if self.activityMonitoring and response["OK"]:
591+
from DIRAC.MonitoringSystem.Client.MonitoringReporter import MonitoringReporter
592+
593+
self.activityMonitoringReporter = MonitoringReporter(monitoringType="ServiceMonitoring")
595594
self.activityMonitoringReporter.addRecord(
596595
{
597596
"timestamp": int(TimeUtilities.toEpochMilliSeconds()),

0 commit comments

Comments
 (0)