File indexing completed on 2026-04-10 08:38:58
0001 import datetime
0002 import multiprocessing
0003 import sys
0004
0005 from pandacommon.pandautils.PandaUtils import naive_utcnow
0006
0007 from pandaserver.srvcore import CoreUtils
0008
0009
0010
0011 class ProcessWrapper(multiprocessing.Process):
0012
0013 def __init__(self, target, args):
0014 multiprocessing.Process.__init__(self, target=self.wrappedMain)
0015 self.target = target
0016 self.args = args
0017
0018
0019 def wrappedMain(self):
0020 while True:
0021 proc = multiprocessing.Process(target=self.target, args=self.args)
0022 proc.start()
0023 pid = proc.pid
0024 while True:
0025 try:
0026 proc.join(20)
0027 if not CoreUtils.checkProcess(pid):
0028 timeNow = naive_utcnow()
0029 print(f"{str(timeNow)} {self.__class__.__name__}: INFO pid={pid} not exist")
0030 break
0031 except Exception:
0032 timeNow = naive_utcnow()
0033 errType, errValue = sys.exc_info()[:2]
0034 print(f"{str(timeNow)} {self.__class__.__name__}: INFO failed to check pid={pid} with {errType} {errValue}")