-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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: Fix handling of kernel stderr, and capture stdout and segfaults too (IPython console) #14025
Conversation
@impact27, it seems you haven't pushed your changes to spyder-kernels to a corresponding PR in that repo. |
Fixes #1922 as well |
Should I leave this on 4.x or move it to 5.x? |
@impact27, could you fix the merge conflicts and try to finish this PR as soon as you can? Sorry for the rush, but I need the fixes you're doing here to the console shutdown logic to finish PR #16409. That's because our tests are failing with a segfault there, which seems related to the problem @rear1019 was trying to solve on PR #16585. |
Let me know if you need help with that, so you can keep working on this. |
737d9b5
to
a0e9b6a
Compare
@ccordoba12 Depends on jupyter/qtconsole#505 |
@ccordoba12 The tests might pass without jupyter/qtconsole#505. When it is merged the last commit can be removed and the tests will be more stable. |
|
||
def __del__(self): | ||
"""Close threads to avoid segfault""" | ||
"""Close threads to avoid segfault.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is likely an issue as well, but not covered in this PR. Don't close spyder while restarting a kernel?
…der-ide/spyder-kernels.git external-deps/spyder-kernels subrepo: subdir: "external-deps/spyder-kernels" merged: "efe0a3f22" upstream: origin: "https://github.com/spyder-ide/spyder-kernels.git" branch: "2.x" commit: "efe0a3f22" git-subrepo: version: "0.4.1" origin: "https://github.com/ingydotnet/git-subrepo" commit: "a04d8c2"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @impact27 for this improvement! It looks really good to me, except for the minor comments and suggestions I left below.
Also, I have a question for you: does this new functionality not replace what Wurlitzer does? If that's the case, should we not remove Wurlitzer from the kernel dependencies?
@@ -478,7 +558,10 @@ def stop_button_click_handler(self): | |||
|
|||
def show_kernel_error(self, error): | |||
"""Show kernel initialization errors in infowidget.""" | |||
InstallerIPythonKernelError(error) | |||
self.error_text = error | |||
if "issue1666807" not in error: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really ugly and it could lead to problems when building the installer for publishing it.
@mrclary, what do you think about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@impact27, what is the significance of "issue1666807"? InstallerIPythonKernelError
is perfectly safe to execute under any circumstance, so does not require flow control. InstallerIPythonKernelError
will not do anything unless the installer test is running, i.e. the system environment variable INSTALLER_TEST=1
; this only occurs on the GitHub server when explicitly testing the macOS application build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When building the installer, the work in this PR reveals that an error is printer relative to https://bugs.python.org/issue1666807. Basically python complains that some paths are relative and not absolute. I guess this is made to have a portable installer. I don't think the code here creates this error but rather reveals it. I will remove this but I think this will make the installer tests fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error in the Create macOS App Bundle and DMG / macOS App Bundle (Lite)
test:
This version of python seems to be incorrectly compiled
(internal generated filenames are not absolute).
This may make the debugger miss breakpoints.
Related bug: http://bugs.python.org/issue1666807
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I've seen this happen recently. It is not related to anything in this PR and this PR did not uncover it. As far as this PR is concerned, that is good news. I was not aware, however, that it was causing the installer test to fail. AFAIK, this may not present an actual issue when using Spyder, but nevertheless needs to be addressed. I'll look into it right away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, quick clarification. This warning printed in the IPython console began showing up recently, but did not cause the installer to fail. This PR did begin causing the installer to fail; I assume that it was not captured before this PR. I don't know how malicious this warning is, but I'll try to find the root cause.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could add back the if "issue1666807" not in error:
so the tests pass and add an issue to the issue tracker so this can be handled separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, I think that is our only option right now. This issue has me stumped. I think we should reopen #16828 rather than creating a new issue.
This approach wouldn't work for kernels not started by spyder, so Wurlitzer might still be useful. |
Co-authored-by: Carlos Cordoba <ccordoba12@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Carlos Cordoba <ccordoba12@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a terrific improvement! Thanks a lot @impact27 for your work on this!
Description of Changes
Sometines, c libraries will print something to the actual stdout and stderr, instead of using the ipykernel ones. This saves these messages to a file and displays them in the console.
Issue(s) Resolved
Fixes #13991
Fixes #9759
Fixes #1922
Depends on #16766
Depends on jupyter/qtconsole#450
Affirmation
By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.
I certify the above statement is true and correct: