Back to home page

EIC code displayed by LXR

 
 

    


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

0001 import os
0002 import socket
0003 
0004 from pandajedi.jedicore import Interaction
0005 
0006 
0007 # base class for watchdog
0008 class WatchDogBase(object):
0009     """
0010     Base class for watchdog
0011     """
0012 
0013     # constructor
0014     def __init__(self, taskBufferIF, ddmIF):
0015         self.taskBufferIF = taskBufferIF
0016         self.ddmIF = ddmIF
0017         self.pid = f"{socket.getfqdn().split('.')[0]}-{os.getpid()}-dog"
0018         self.vo = None
0019         self.refresh()
0020 
0021     def get_process_lock(self, component, timeLimit=5, **kwargs):
0022         """
0023         Shortcut of get process lock for watchdog action methods
0024 
0025         Args:
0026         component (str): spec of the request
0027         timeLimit (int): lifetime of the lock in minutes
0028         **kwargs: other arguments for taskBufferIF.lockProcess_JEDI
0029 
0030         Returns:
0031             bool : True if got lock, False otherwise
0032         """
0033         return self.taskBufferIF.lockProcess_JEDI(
0034             vo=self.vo,
0035             prodSourceLabel=kwargs.get("prodSourceLabel", "default"),
0036             cloud=kwargs.get("cloud", None),
0037             workqueue_id=kwargs.get("workqueue_id", None),
0038             resource_name=kwargs.get("resource_name", None),
0039             component=component,
0040             pid=self.pid,
0041             timeLimit=timeLimit,
0042         )
0043 
0044     # refresh
0045     def refresh(self):
0046         self.siteMapper = self.taskBufferIF.get_site_mapper()
0047 
0048     # pre-action
0049     def pre_action(self, tmpLog, vo, prodSourceLabel, pid, *args, **kwargs):
0050         pass
0051 
0052 
0053 Interaction.installSC(WatchDogBase)