Skip to content

Commit 9e55212

Browse files
committed
Simplify and remove unused context manager
1 parent 4501fd9 commit 9e55212

1 file changed

Lines changed: 1 addition & 12 deletions

File tree

ipykernel/zmqshell.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import threading
2121
import typing
2222
import warnings
23-
from contextlib import contextmanager
2423
from pathlib import Path
2524
from subprocess import CalledProcessError
2625

@@ -766,10 +765,9 @@ def get_parent(self):
766765
def set_thread_parent(self, parent):
767766
"""Set the parent header for only the current thread associating output with its triggering input"""
768767
tokens = [(self._parent_header.reset, self._parent_header.set(parent))]
769-
objs: list[typing.Any] = [self.displayhook, self.display_pub]
768+
objs: list[typing.Any] = [self.displayhook, self.display_pub, sys.stdout, sys.stderr]
770769
if hasattr(self, "_data_pub"):
771770
objs.append(self.data_pub)
772-
objs += [sys.stdout, sys.stderr]
773771
for obj in objs:
774772
set_thread = getattr(obj, "set_thread_parent", None)
775773
if set_thread is not None:
@@ -781,15 +779,6 @@ def reset_thread_parent(self, tokens):
781779
for reset, token in reversed(tokens):
782780
reset(token)
783781

784-
@contextmanager
785-
def parent_override(self, parent):
786-
"""Context manager to temporarily set the thread's parent header"""
787-
tokens = self.set_thread_parent(parent)
788-
try:
789-
yield
790-
finally:
791-
self.reset_thread_parent(tokens)
792-
793782
def init_magics(self):
794783
"""Initialize magics."""
795784
super().init_magics()

0 commit comments

Comments
 (0)