Skip to content

Commit 3f31b8f

Browse files
authored
add 'with' support (#11)
1 parent 5c230fd commit 3f31b8f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

axengine/session.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ def __init__(
157157
def __del__(self):
158158
self._final()
159159

160+
def __enter__(self):
161+
return self
162+
163+
def __exit__(self, exc_type, exc_value, traceback):
164+
self._final()
165+
160166
def _init(self, vnpu=VNPUType.DISABLED): # vnpu type, the default is disabled
161167
ret = self._sys_lib.AX_SYS_Init()
162168
if 0 != ret:

0 commit comments

Comments
 (0)