Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Destroy tk app to avoid memory leak #1008

Merged
merged 2 commits into from
Oct 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ipykernel/eventloops.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ def process_stream_events(stream, *a, **kw):
if stream.flush(limit=1):
app.tk.deletefilehandler(stream.getsockopt(zmq.FD))
app.quit()
app.destroy()
del kernel.app_wrapper

# For Tkinter, we create a Tk object and call its withdraw method.
kernel.app_wrapper = BasicAppWrapper(app)
Expand Down Expand Up @@ -297,7 +299,8 @@ def start(self):
def loop_tk_exit(kernel):
try:
kernel.app_wrapper.app.destroy()
except RuntimeError:
del kernel.app_wrapper
except (RuntimeError, AttributeError):
pass


Expand Down