Nicer standalone engine inferface (#4480)

This commit is contained in:
Yinghai Lu
2025-03-17 01:42:04 -07:00
committed by GitHub
parent 927ca935a7
commit c614dbdf95

View File

@@ -249,6 +249,13 @@ class Engine:
"""Shutdown the engine"""
kill_process_tree(os.getpid(), include_parent=False)
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, traceback):
self.shutdown()
return False
def start_profile(self):
loop = asyncio.get_event_loop()
loop.run_until_complete(self.tokenizer_manager.start_profile())