From 2b00e2d17042eba9c08a879db5842b98311ac4ef Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Thu, 26 Jun 2025 10:06:09 +0200 Subject: log unhandled exceptions from run_in_fork --- linuxnamespaces/__init__.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'linuxnamespaces/__init__.py') diff --git a/linuxnamespaces/__init__.py b/linuxnamespaces/__init__.py index ab8fa40..a1f790e 100644 --- a/linuxnamespaces/__init__.py +++ b/linuxnamespaces/__init__.py @@ -9,6 +9,7 @@ import asyncio import contextlib import errno import fcntl +import logging import os import pathlib import socket @@ -22,6 +23,9 @@ from .atlocation import * from .syscalls import * +_logger = logging.getLogger(__name__) + + class run_in_fork: """Decorator for running the decorated function once in a separate process. """ @@ -46,6 +50,9 @@ class run_in_fork: except SystemExit as err: code = err.code except: + _logger.exception( + "uncaught exception in run_in_fork %r", function + ) code = 1 os._exit(code) @@ -115,6 +122,9 @@ class async_run_in_fork: except SystemExit as err: code = err.code except: + _logger.exception( + "uncaught exception in run_in_fork %r", function + ) code = 1 os._exit(code) watcher.add_child_handler(self.pid, self._child_callback) -- cgit v1.2.3