Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-11 08:41:04

0001 #!/usr/bin/env python
0002 # Licensed under the Apache License, Version 2.0 (the "License");
0003 # you may not use this file except in compliance with the License.
0004 # You may obtain a copy of the License at
0005 # http://www.apache.org/licenses/LICENSE-2.0
0006 #
0007 # Authors:
0008 # - Wen Guan, wen.guan@cern.ch, 2017
0009 
0010 import logging
0011 
0012 from pilot.eventservice.esprocess.esprocess import ESProcess
0013 from pilot.eventservice.esprocess.eshook import ESHook
0014 
0015 logger = logging.getLogger(__name__)
0016 
0017 """
0018 ES manager to setup and run ESProcess.
0019 """
0020 
0021 
0022 class ESManager:
0023     def __init__(self, hook):
0024         """
0025         Initialization: setup ES hooks.
0026 
0027         :param hook: an instance of ESHook.
0028         """
0029         logger.info('initializing hooks')
0030         if not isinstance(hook, ESHook):
0031             raise Exception("hook(%s) is not instance of %s" % (hook, ESHook))
0032 
0033         self.__hook = hook
0034         logger.info('initialized hooks')
0035 
0036     def run(self):
0037         """
0038         Initialize and run ESProcess.
0039         """
0040 
0041         logger.debug('gettting payload')
0042         payload = self.__hook.get_payload()
0043         logger.debug('got payload: %s' % payload)
0044 
0045         logger.info('init ESProcess')
0046         process = ESProcess(payload)
0047         process.set_get_event_ranges_hook(self.__hook.get_event_ranges)
0048         process.set_handle_out_message_hook(self.__hook.handle_out_message)
0049 
0050         logger.info('ESProcess starts to run')
0051         process.start()
0052         process.join()
0053         logger.info('ESProcess finishes')