MCPcopy Index your code
hub / github.com/PaddlePaddle/FastDeploy / run_engine

Method run_engine

fastdeploy/engine/async_llm.py:131–160  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

129 self.shutdown_signal = multiprocessing.Value("i", 0) # 0=running, 1=shutdown
130
131 def run_engine():
132 engine = None
133
134 def signal_handler(signum, frame):
135 llm_logger.info(f"Engine process received signal {signum}, initiating shutdown...")
136 if engine:
137 engine.running = False
138
139 # Register signal handlers
140 signal.signal(signal.SIGTERM, signal_handler)
141 signal.signal(signal.SIGINT, signal_handler)
142
143 try:
144 engine = EngineService(self.cfg, use_async_llm=True)
145 # Start engine with ZMQ service
146 engine.start(async_llm_pid=self.engine_pid)
147
148 # Keep engine running until shutdown signal is received
149 while self.shutdown_signal.value == 0 and getattr(engine, "running", True):
150 time.sleep(0.5)
151
152 except Exception as e:
153 llm_logger.error(f"Engine process error: {e}, {str(traceback.format_exc())}")
154 finally:
155 if engine and hasattr(engine, "_exit_sub_services"):
156 try:
157 engine._exit_sub_services()
158 llm_logger.info("Engine process cleanup completed")
159 except Exception as e:
160 llm_logger.error(f"Error during engine cleanup: {e}")
161
162 self.engine_process = multiprocessing.Process(target=run_engine)
163 self.engine_process.start()

Callers

nothing calls this directly

Calls 6

startMethod · 0.95
_exit_sub_servicesMethod · 0.95
EngineServiceClass · 0.90
sleepMethod · 0.45
errorMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected