-
-
Notifications
You must be signed in to change notification settings - Fork 367
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
OutStream.close raises if watchfd=False
#867
Comments
Here's a minimal reproducer on my machine: import zmq
from jupyter_client.session import Session
from ipykernel.iostream import OutStream, IOPubThread
def test():
context = zmq.Context()
pub_thread = IOPubThread(socket=context.socket(zmq.PUB))
pub_thread.start()
stream = OutStream(
session=Session(),
pub_thread=pub_thread,
name="stderr",
watchfd=False,
)
stream.close()
pub_thread.stop()
context.destroy()
test() Here's a complete session: where I:
|
This was referenced Feb 16, 2022
mdickinson
added a commit
to enthought/envisage
that referenced
this issue
Jan 5, 2023
This PR contains some minor compatibility fixes for ipykernel versions 6.0.0 and later. There's still significant work to do before we have full compatibility - this is really just clearing away some of the weeds so that we can see the real issues. Details - We use `capture_fd_output=False` when creating the `IPKernelApp`. This prevents the kernel application from setting up threads for stdout and stderr redirection. Those threads have been causing shutdown issues. - In `log_connection_info`, we set either the `_ports` traitlet or the `ports` traitlet; whichever works first (this trait was renamed at some point in the ipykernel history) - We retrieve the history manager earlier so that we can shut its bits down - the new `ipykernel` sets the history manager trait to `None` when `atexit_operations` is called, so that we can no longer retrieve the history manager _after_ calling `atexit_operations`. - the most recent `IPython` has deleted the `IPython.utils.io.stdout` and `IPython.utils.io.stderr` attributes; update our cleanup code to allow for this case Related upstream issues: - ipython/ipykernel#867 - ipython/ipykernel#868
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Closing an
OutStream
instance via itsclose
method fails if thatOutStream
instance is created withwatchfd=False
, with an exceptionAttributeError: 'OutStream' object has no attribute 'watch_fd_thread'
.Here's a full traceback from some Envisage tests. We're creating a kernel app with
kernel = IPKernelApp.instance(capture_fd_output=False)
, and then later shutting that kernel down. Only the last two lines are directly relevant foripykernel
. I'll see if I can come up with a more self-contained reproducer.From the source, the cause looks fairly clear: at
OutStream
creation time, the_should_watch
andwatch_fd_thread
attributes are only created ifwatchfd=True
, but theclose
method assumes that both attributes exist unconditionally. (Well, at least on Linux and macOS, anyway.)ipykernel version: 6.9.1
Python version: 3.10.2
OS + hardware: macOS 11.6.3 (Big Sur), Intel MacBook Pro
The text was updated successfully, but these errors were encountered: