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

jp_serverapp pytest fixture clears all logging handlers #585

Closed
Zsailer opened this issue Oct 1, 2021 · 0 comments · Fixed by #588
Closed

jp_serverapp pytest fixture clears all logging handlers #585

Zsailer opened this issue Oct 1, 2021 · 0 comments · Fixed by #588

Comments

@Zsailer
Copy link
Member

Zsailer commented Oct 1, 2021

The Jupyter Server pytest plugin fixture, jp_serverapp, removes all handlers from the core application logger. This means that if you want to add/test custom log handlers to the application logger, you'll have to re-add these manually inside unit tests. This isn't great for end-to-end testing.

I think I originally cleared the handlers to avoid colliding with the stdout/stderr streams started by pytest. Pytest hijacks these stream and sometimes closes them before the server is done emitting logs, particularly in the case where kernels are still shutting down after a unit test.

Really, this is a symptom of a deeper issue. The _cleanup() method on the ServerApp calls cleanup on kernels and terminals. It calls run_sync is both cases, and returns a Future. This Future is never awaited, which when testing, introduces a race condition between the teardown of the unit test and the serverapp.

We can address the first issue, removing the logging handers, but rerouting the core application StreamHandler to something other than stderr/stdout.

The second issue likely needs some more discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant