Skip to content

eventloop error on exit with wx and ipykernel 7.1.0 #1477

@newville

Description

@newville

Using wx as a GUI backend for plotting with matplotlib, I'm seeing eventloop errors on exiting Jupyter (console or lab) that look like

Traceback (most recent call last):
  File "/.../lib/python3.13/site-packages/ipykernel/eventloops.py", line 213, in on_timer
    self.func()
    ~~~~~~~~~^^
  File "/.../lib/python3.13/site-packages/ipykernel/eventloops.py", line 197, in wake
    if shell_stream.flush(limit=1):
       ~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/.../lib/python3.13/site-packages/zmq/eventloop/zmqstream.py", line 450, in flush
    self._check_closed()
    ~~~~~~~~~~~~~~~~~~^^
  File "/.../lib/python3.13/site-packages/zmq/eventloop/zmqstream.py", line 651, in _check_closed
    raise OSError("Stream is closed")
OSError: Stream is closed

usually repeating several (perhaps a dozen) times.

I see #1458 fixed several eventloop issues for plotting with matplotlib.

I believe the eventloops.loop_wx function could be improved to avoid these messages, and I will post a candidate PR.

For reference, I am trying to improve the combination of (my own) wxmplot.interactive plotting package (https://newville.github.io/wxmplot/index.html) with ipython/jupyter. This works well, but I would prefer to avoid the errors on exit.

I looked into monkey-patching the eventloops.loop_wx, but I believe the registration system makes this difficult, and it would not be anyone's preferred approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions