From bd9a74da0dcfe1635ea51cfe7dd64a33da70491a Mon Sep 17 00:00:00 2001 From: Aaron Abbott Date: Thu, 10 Oct 2024 21:21:09 +0000 Subject: [PATCH] Fixed with weakref, needs to be done in other signals too --- .../opentelemetry/sdk/metrics/_internal/export/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/export/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/export/__init__.py index 4acf1cc81d..bdb4183499 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/export/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/export/__init__.py @@ -22,6 +22,7 @@ from threading import Event, Lock, RLock, Thread from time import time_ns from typing import IO, Callable, Dict, Iterable, Optional +import weakref from typing_extensions import final @@ -490,8 +491,9 @@ def __init__( ) self._daemon_thread.start() if hasattr(os, "register_at_fork"): + weakself = weakref.proxy(self) os.register_at_fork( - after_in_child=self._at_fork_reinit + after_in_child=lambda: weakself._at_fork_reinit() ) # pylint: disable=protected-access elif self._export_interval_millis <= 0: raise ValueError(