Skip to content

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

Open
ncoop57 wants to merge 1 commit into
mainfrom
in-notebook
Open

Use in_notebook() function instead of IN_NOTEBOOK constant#1636
ncoop57 wants to merge 1 commit into
mainfrom
in-notebook

Conversation

@ncoop57

@ncoop57 ncoop57 commented Aug 24, 2026

Copy link
Copy Markdown

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
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.

1 participant