Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 08:38:58

0001 import random
0002 import sys
0003 import time
0004 
0005 from pandajedi.jedicore import Interaction
0006 from pandajedi.jedicore.ThreadUtils import ZombieCleaner
0007 
0008 
0009 class JediKnight(Interaction.CommandReceiveInterface):
0010     # constructor
0011     def __init__(self, commuChannel, taskBufferIF, ddmIF, logger, **kwargs):
0012         Interaction.CommandReceiveInterface.__init__(self, commuChannel)
0013         self.taskBufferIF = taskBufferIF
0014         self.ddmIF = ddmIF
0015         self.logger = logger
0016         # intra-node message broker proxies
0017         self.mb_proxy_dict = kwargs.get("mb_proxy_dict")
0018         # start zombie cleaner
0019         ZombieCleaner().start()
0020 
0021     # start communication channel in a thread
0022     def start(self):
0023         # start communication channel
0024         import threading
0025 
0026         thr = threading.Thread(target=self.startImpl)
0027         thr.start()
0028 
0029     # implementation of start()
0030     def startImpl(self):
0031         try:
0032             Interaction.CommandReceiveInterface.start(self)
0033         except Exception:
0034             errtype, errvalue = sys.exc_info()[:2]
0035             self.logger.error(f"crashed in JediKnight.startImpl() with {errtype.__name__} {errvalue}")
0036 
0037     # parse init params
0038     def parseInit(self, par):
0039         if isinstance(par, list):
0040             return par
0041         try:
0042             return par.split("|")
0043         except Exception:
0044             return [par]
0045 
0046     # sleep to avoid synchronization of loop
0047     def randomSleep(self, min_val=0, default_max_val=30, max_val=None):
0048         if max_val is None:
0049             max_val = default_max_val
0050         max_val = min(max_val, default_max_val)
0051         time.sleep(random.randint(min_val, max_val))
0052 
0053 
0054 # install SCs
0055 Interaction.installSC(JediKnight)