From 8d8d477380475fd9743513f5740ec5516c59417b Mon Sep 17 00:00:00 2001 From: kaclohol <314377460@qq.com> Date: Mon, 9 Dec 2024 11:17:57 +0800 Subject: [PATCH] add 'with' support --- axengine/session.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/axengine/session.py b/axengine/session.py index 0e16142..6981dd7 100644 --- a/axengine/session.py +++ b/axengine/session.py @@ -157,6 +157,12 @@ def __init__( def __del__(self): self._final() + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self._final() + def _init(self, vnpu=VNPUType.DISABLED): # vnpu type, the default is disabled ret = self._sys_lib.AX_SYS_Init() if 0 != ret: