Skip to content

Use in_notebook() function instead of IN_NOTEBOOK constant - #1636

Merged
jph00 merged 2 commits into
mainfrom
in-notebook
Sep 9, 2026
Merged

Use in_notebook() function instead of IN_NOTEBOOK constant#1636
jph00 merged 2 commits into
mainfrom
in-notebook

Conversation

@ncoop57

@ncoop57 ncoop57 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Replaces the module-level IN_NOTEBOOK constant with calls to the in_notebook() function so the notebook check is evaluated at call time rather than at import time.

Changes

  • nbdev/serve.py: proc_nbs now calls in_notebook() when choosing the parallel start method
  • nbdev/test.py: test_nb and nbdev_test now call in_notebook() for SIGINT handling, IN_TEST env var, and start method selection
  • nbdev/__init__.py: added a trigger note to the nbdev.skill module docs

Why

Evaluating at import time means the value is fixed regardless of the actual runtime environment (e.g. in spawned/forked workers, or when imported before a notebook kernel is established). Calling in_notebook() gives the correct answer at the point of use.

@ncoop57 ncoop57 added the enhancement New feature or request label Aug 24, 2026
@ncoop57
ncoop57 requested a review from jph00 August 24, 2026 18:26
@jph00
jph00 merged commit 8a42e3c into main Sep 9, 2026
0 of 8 checks passed
@jph00
jph00 deleted the in-notebook branch September 9, 2026 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants