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

stdout and stderr display nothing if it's from other thread of logging.QueueListener #16381

Open
1 of 2 tasks
NewUserHa opened this issue Jan 17, 2025 · 5 comments
Open
1 of 2 tasks
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster notebook-execution Kernels issues (start/restart/switch/execution, install ipykernel)

Comments

@NewUserHa
Copy link

NewUserHa commented Jan 17, 2025

Applies To

  • Notebooks (.ipynb files)
  • Interactive Window and/or Cell Scripts (.py files with #%% markers)

What happened?

import logging.handlers
import queue, logging
import sys
que=queue.Queue()
handler = logging.StreamHandler(sys.stdout)
listener = logging.handlers.QueueListener(que,  handler)
queue_handler = logging.handlers.QueueHandler(que)
root = logging.getLogger()
root.addHandler(queue_handler)
# root.addHandler(handler)
logging.lastResort=None
listener.start()

root.warning("Look out!")

# listener.stop()

then, the second time run the below lines, it starts to output nothing.

root.setLevel(logging.DEBUG)
root.debug('debug test')

But in ipython, it works fine

VS Code Version

1.95.3

Jupyter Extension Version

v2024.10.0

Jupyter logs

Coding Language and Runtime Version

python 3.12.6

Language Extension Version (if applicable)

v2024.22.2

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Local

@NewUserHa NewUserHa added the bug Issue identified by VS Code Team member as probable bug label Jan 17, 2025
@DonJayamanne
Copy link
Contributor

Thank you for filing this issue and sorry you are running into this.
I'm unable to repro this issue at my end.
I've tried this with the latest version of Jupyter pre-release version and latest vscode insiders. It works as expected.
However what I've noticed is, in order to get subsequent outupts from the second cell, i have to run the first cell again.

I can repro this same issue with Jupyter Lab as well, please can you try jupyter lab (instead of ipython terminal, as thats different)

@DonJayamanne DonJayamanne added info-needed Issue requires more information from poster notebook-execution Kernels issues (start/restart/switch/execution, install ipykernel) labels Jan 17, 2025
@NewUserHa
Copy link
Author

I'm unable to repro this issue at my end.

unable?

@NewUserHa
Copy link
Author

However what I've noticed is, in order to get subsequent outupts from the second cell, i have to run the first cell again.

I think that's because it's a clean new thread/new QueueListener, so it worked.

I can repro this same issue with Jupyter Lab as well, please can you try jupyter lab (instead of ipython terminal, as thats different)

with Jupyter Lab locally, just tested, it can always correctly logging to the output of the first cell

@DonJayamanne
Copy link
Contributor

with Jupyter Lab locally, just tested, it can always correctly logging to the output of the first cell

Not sure what you mean

Please can you install vscode insiders, latest pre-release version of Jupyter extension and the latest pre-release version of Notebook Renderers and try this again.

Once done, please can you try to record the screen with jupyter lab and vscode side by side so I can understand exactly what you mean. you can use something like gifcap.dev to record your screen and upload the final gif file.

@NewUserHa
Copy link
Author

Not sure what you mean

tried in Jupyter Lab, the example code works without any issue, the following run root.debug('debug test'), the log is outputted to the output area of the first cell (i.e. just below that code block rather than the other cells) of in the Jupyter Lab.

Please can you install vscode insiders, latest pre-release version of Jupyter extension and the latest pre-release version of Notebook Renderers and try this again.

is there any changes for the issue has made to try?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster notebook-execution Kernels issues (start/restart/switch/execution, install ipykernel)
Projects
None yet
Development

No branches or pull requests

2 participants