summaryrefslogtreecommitdiff
path: root/linuxnamespaces/__init__.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2025-06-26 10:06:09 +0200
committerHelmut Grohne <helmut@subdivi.de>2025-06-26 10:06:09 +0200
commit2b00e2d17042eba9c08a879db5842b98311ac4ef (patch)
tree2e9711996d71e6636f7fee7c37de14546de9cd76 /linuxnamespaces/__init__.py
parent3f9a84e461d5ceb31dc20f9d2a21fa729d937db1 (diff)
downloadpython-linuxnamespaces-2b00e2d17042eba9c08a879db5842b98311ac4ef.tar.gz
log unhandled exceptions from run_in_fork
Diffstat (limited to 'linuxnamespaces/__init__.py')
-rw-r--r--linuxnamespaces/__init__.py10
1 files changed, 10 insertions, 0 deletions
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)