Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: catch exception in async python extensions #340

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,59 +131,59 @@ async def _wrapper_on_config(self, async_ten_env: AsyncTenEnv):
try:
await self.on_configure(async_ten_env)
except Exception as e:
_exit_on_exception(async_ten_env, e)
self._exit_on_exception(async_ten_env, e)

async def _wrapper_on_init(self, async_ten_env: AsyncTenEnv):
try:
await self.on_init(async_ten_env)
except Exception as e:
_exit_on_exception(async_ten_env, e)
self._exit_on_exception(async_ten_env, e)

async def _wrapper_on_start(self, async_ten_env: AsyncTenEnv):
try:
await self.on_start(async_ten_env)
except Exception as e:
_exit_on_exception(async_ten_env, e)
self._exit_on_exception(async_ten_env, e)

async def _wrapper_on_stop(self, async_ten_env: AsyncTenEnv):
try:
await self.on_stop(async_ten_env)
except Exception as e:
_exit_on_exception(async_ten_env, e)
self._exit_on_exception(async_ten_env, e)

async def _wrapper_on_deinit(self, async_ten_env: AsyncTenEnv):
try:
await self.on_deinit(async_ten_env)
except Exception as e:
_exit_on_exception(async_ten_env, e)
self._exit_on_exception(async_ten_env, e)

async def _wrapper_on_cmd(self, async_ten_env: AsyncTenEnv, cmd: Cmd):
try:
await self.on_cmd(async_ten_env, cmd)
except Exception as e:
_exit_on_exception(async_ten_env, e)
self._exit_on_exception(async_ten_env, e)

async def _wrapper_on_data(self, async_ten_env: AsyncTenEnv, data: Data):
try:
await self.on_data(async_ten_env, data)
except Exception as e:
_exit_on_exception(async_ten_env, e)
self._exit_on_exception(async_ten_env, e)

async def _wrapper_on_video_frame(
self, async_ten_env: AsyncTenEnv, video_frame: VideoFrame
):
try:
await self.on_video_frame(async_ten_env, video_frame)
except Exception as e:
_exit_on_exception(async_ten_env, e)
self._exit_on_exception(async_ten_env, e)

async def _wrapper_on_audio_frame(
self, async_ten_env: AsyncTenEnv, audio_frame: AudioFrame
):
try:
await self.on_audio_frame(async_ten_env, audio_frame)
except Exception as e:
_exit_on_exception(async_ten_env, e)
self._exit_on_exception(async_ten_env, e)

def _exit_on_exception(self, async_ten_env: AsyncTenEnv, e: Exception):
traceback_info = traceback.format_exc()
Expand Down