From 873fc8e2282acc9f7b44b35e9d8275807ed8b825 Mon Sep 17 00:00:00 2001 From: Piotr Kasprzyk <14312755+pkasprzyk@users.noreply.github.com> Date: Thu, 25 Nov 2021 08:48:06 +0100 Subject: [PATCH] Fixed multithreading bug with StdStreamCaptureLogger (#762) * Fixed multithreading bug with StdStreamCaptureLogger * fix changelog --- CHANGELOG.md | 5 +++++ neptune/new/internal/streams/std_stream_capture_logger.py | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c08a314f..0a0e1f175 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## neptune-client 0.13.3 + +### Fixes +- Fixed multithreading bug with StdStreamCaptureLogger ([#762](https://github.com/neptune-ai/neptune-client/pull/762)) + ## neptune-client 0.13.2 ### Fixes diff --git a/neptune/new/internal/streams/std_stream_capture_logger.py b/neptune/new/internal/streams/std_stream_capture_logger.py index c09381873..b4e664f92 100644 --- a/neptune/new/internal/streams/std_stream_capture_logger.py +++ b/neptune/new/internal/streams/std_stream_capture_logger.py @@ -28,14 +28,14 @@ def __init__(self, run: Run, attribute_name: str, stream: TextIO): self._logger = NeptuneLogger(run, attribute_name) self.stream = stream self._thread_local = threading.local() - self._thread_local.enabled = True + self.enabled = True def write(self, data: str): if not hasattr(self._thread_local, "inside_write"): self._thread_local.inside_write = False self.stream.write(data) - if self._thread_local.enabled and not self._thread_local.inside_write: + if self.enabled and not self._thread_local.inside_write: try: self._thread_local.inside_write = True self._logger.log(data) @@ -46,7 +46,7 @@ def __getattr__(self, attr): return getattr(self.stream, attr) def close(self): - self._thread_local.enabled = False + self.enabled = False class StdoutCaptureLogger(StdStreamCaptureLogger):