diff --git a/nbdev/serve.py b/nbdev/serve.py index d80d3cd07..cc073df0b 100644 --- a/nbdev/serve.py +++ b/nbdev/serve.py @@ -87,7 +87,7 @@ def proc_nbs( (cache/'_quarto.yml').unlink(missing_ok=True) # single-doc renders strip the staged copy in place (`_strip_sidebar`), so always restage it files = files.map(_proc_file, mtime=cache_mtime, cache=cache, path=path).filter() - kw = {} if IN_NOTEBOOK else {'method':'spawn'} + kw = {} if in_notebook() else {'method':'spawn'} parallel(nbdev.serve_drv.main, files, n_workers=n_workers, pause=0.01, **kw) if cache.exists(): cache.touch() return cache diff --git a/nbdev/test.py b/nbdev/test.py index 2696c116c..9dcd21eb2 100644 --- a/nbdev/test.py +++ b/nbdev/test.py @@ -92,12 +92,12 @@ def test_nb( cell_timing_min:float=None # print cells slower than this many seconds (None: no timing output) ): "Execute tests in notebook in `fn` except those with `skip_flags`" - if not IN_NOTEBOOK and threading.current_thread() is threading.main_thread(): signal.signal(signal.SIGINT, _int_handler) + if not in_notebook() and threading.current_thread() is threading.main_thread(): signal.signal(signal.SIGINT, _int_handler) fn = Path(fn) _cur_nb[0] = fn if basepath: sys.path.insert(0, str(basepath)) prev_test = os.environ.get('IN_TEST') - if not IN_NOTEBOOK: os.environ['IN_TEST'] = '1' + if not in_notebook(): os.environ['IN_TEST'] = '1' try: nb = NBProcessor(fn, rm_directives=False, process=True).nb fm = nb_frontmatter(nb) @@ -167,7 +167,7 @@ def nbdev_test( if len(files)==0: return print('No files were eligible for testing') if n_workers is None: n_workers = 0 if len(files)==1 else min(num_cpus(), 8) - if IN_NOTEBOOK: kw = {'method':'spawn'} if os.name=='nt' or sys.platform=='darwin' else {'method':'forkserver'} + if in_notebook(): kw = {'method':'spawn'} if os.name=='nt' or sys.platform=='darwin' else {'method':'forkserver'} else: kw = {'method':'spawn'} if sys.platform=='darwin' else {} wd_pth = cfg.nbs_path with working_directory(wd_pth if (wd_pth and wd_pth.exists()) else os.getcwd()): diff --git a/nbs/api/12_test.ipynb b/nbs/api/12_test.ipynb index de3a301c0..6e2177407 100644 --- a/nbs/api/12_test.ipynb +++ b/nbs/api/12_test.ipynb @@ -165,12 +165,12 @@ " cell_timing_min:float=None # print cells slower than this many seconds (None: no timing output)\n", "):\n", " \"Execute tests in notebook in `fn` except those with `skip_flags`\"\n", - " if not IN_NOTEBOOK and threading.current_thread() is threading.main_thread(): signal.signal(signal.SIGINT, _int_handler)\n", + " if not in_notebook() and threading.current_thread() is threading.main_thread(): signal.signal(signal.SIGINT, _int_handler)\n", " fn = Path(fn)\n", " _cur_nb[0] = fn\n", " if basepath: sys.path.insert(0, str(basepath))\n", " prev_test = os.environ.get('IN_TEST')\n", - " if not IN_NOTEBOOK: os.environ['IN_TEST'] = '1'\n", + " if not in_notebook(): os.environ['IN_TEST'] = '1'\n", " try:\n", " nb = NBProcessor(fn, rm_directives=False, process=True).nb\n", " fm = nb_frontmatter(nb)\n", @@ -356,7 +356,7 @@ " if len(files)==0: return print('No files were eligible for testing')\n", "\n", " if n_workers is None: n_workers = 0 if len(files)==1 else min(num_cpus(), 8)\n", - " if IN_NOTEBOOK: kw = {'method':'spawn'} if os.name=='nt' or sys.platform=='darwin' else {'method':'forkserver'}\n", + " if in_notebook(): kw = {'method':'spawn'} if os.name=='nt' or sys.platform=='darwin' else {'method':'forkserver'}\n", " else: kw = {'method':'spawn'} if sys.platform=='darwin' else {}\n", " wd_pth = cfg.nbs_path\n", " with working_directory(wd_pth if (wd_pth and wd_pth.exists()) else os.getcwd()):\n", diff --git a/nbs/api/17_serve.ipynb b/nbs/api/17_serve.ipynb index 060ac4e62..e1737ff3c 100644 --- a/nbs/api/17_serve.ipynb +++ b/nbs/api/17_serve.ipynb @@ -199,7 +199,7 @@ " (cache/'_quarto.yml').unlink(missing_ok=True) # single-doc renders strip the staged copy in place (`_strip_sidebar`), so always restage it\n", "\n", " files = files.map(_proc_file, mtime=cache_mtime, cache=cache, path=path).filter()\n", - " kw = {} if IN_NOTEBOOK else {'method':'spawn'}\n", + " kw = {} if in_notebook() else {'method':'spawn'}\n", " parallel(nbdev.serve_drv.main, files, n_workers=n_workers, pause=0.01, **kw)\n", " if cache.exists(): cache.touch()\n", " return cache"