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" ]:
@@ -132,6 +125,10 @@ def initialize(self):
132125 gLogger .exception (errMsg )
133126 return S_ERROR (errMsg )
134127 if self .activityMonitoring :
128+ from DIRAC .MonitoringSystem .Client .MonitoringReporter import MonitoringReporter
129+
130+ self .activityMonitoringReporter = MonitoringReporter (monitoringType = "ServiceMonitoring" )
131+
135132 gThreadScheduler .addPeriodicTask (30 , self .__reportActivity )
136133 gThreadScheduler .addPeriodicTask (100 , self .__activityMonitoringReporting )
137134
@@ -563,6 +560,9 @@ def _executeAction(self, trid, proposalTuple, handlerObj):
563560 retStatus = "OK"
564561 else :
565562 retStatus = "ERROR"
563+ from DIRAC .MonitoringSystem .Client .MonitoringReporter import MonitoringReporter
564+
565+ self .activityMonitoringReporter = MonitoringReporter (monitoringType = "ServiceMonitoring" )
566566 self .activityMonitoringReporter .addRecord (
567567 {
568568 "timestamp" : int (TimeUtilities .toEpochMilliSeconds ()),
@@ -592,6 +592,9 @@ def _mbReceivedMsg(self, trid, msgObj):
592592 handlerObj = result ["Value" ]
593593 response = handlerObj ._rh_executeMessageCallback (msgObj )
594594 if self .activityMonitoring and response ["OK" ]:
595+ from DIRAC .MonitoringSystem .Client .MonitoringReporter import MonitoringReporter
596+
597+ self .activityMonitoringReporter = MonitoringReporter (monitoringType = "ServiceMonitoring" )
595598 self .activityMonitoringReporter .addRecord (
596599 {
597600 "timestamp" : int (TimeUtilities .toEpochMilliSeconds ()),
0 commit comments