Skip to content

Commit

Permalink
PR: Destroy tk app to avoid memory leak (#1008)
Browse files Browse the repository at this point in the history
Co-authored-by: Quentin Peter <quentin.peter@bluewin.ch>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 20, 2022
1 parent a327bcd commit 632a1ba
Showing 1 changed file with 4 additions and 1 deletion.
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

0 comments on commit 632a1ba

Please sign in to comment.