Skip to content

Commit 1b18eef

Browse files
cristipufuclaude
andcommitted
fix: detach utf8_stdout before closing handler to preserve shared buffer
Move the utf8_stdout detach before log_handler.close() so the wrapper is disconnected from sys.stdout.buffer before StreamHandler.close() can cascade a close through it. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f60bd8a commit 1b18eef

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/uipath/runtime/logging/_interceptor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,13 @@ def teardown(self) -> None:
233233
if handler not in self.root_logger.handlers:
234234
self.root_logger.addHandler(handler)
235235

236-
if self._owns_handler:
237-
self.log_handler.close()
238-
239236
if hasattr(self, "utf8_stdout"):
240237
self.utf8_stdout.detach()
241238
del self.utf8_stdout
242239

240+
if self._owns_handler:
241+
self.log_handler.close()
242+
243243
# Only restore streams if we redirected them
244244
if self.original_stdout and self.original_stderr:
245245
sys.stdout = self.original_stdout

0 commit comments

Comments
 (0)