Commit ab82a5e
committed
fix(tinytorch): tito module start/resume/view leak untracked Jupyter Lab processes
Bug
Every tito module start (without --no-jupyter), resume, or view call
launches a brand new jupyter lab subprocess.Popen with no PID
tracking, no cleanup, and no check for whether one is already running.
Over a normal working session where a student opens several modules,
these accumulate indefinitely: confirmed 45 leaked processes after
routine module-by-module testing, and separately confirmed that a
build-up of ~38 live kernels was enough to make the Jupyter Lab UI
itself sluggish (menu clicks timing out).
Fix
Track the launched Jupyter Lab process's PID in .tito/jupyter.pid.
Before launching a new one, check whether that PID is still alive and
is actually still a jupyter process (guards against a recycled PID
being mistaken for a live server). If so, reuse it: tell the student
which notebook to open in their existing tab instead of spawning
another server. Only launch a new process if no tracked server is
currently running.
Testing
Verified against a fresh dev install with all 20 modules completed:
- First tito module view 01: launches Jupyter Lab as before, records
its PID.
- Second tito module view 01 (simulating a student opening another
module in the same session): before the fix, this would spawn a
second full Jupyter Lab server. After the fix, detects the existing
PID, prints "Jupyter Lab is already running (pid N)" with the
notebook to open, and spawns nothing. Confirmed via process listing
that the jupyter.exe count stayed at 1 across both calls.1 parent efefaf9 commit ab82a5e
1 file changed
Lines changed: 52 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
501 | 501 | | |
502 | 502 | | |
503 | 503 | | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
504 | 538 | | |
505 | 539 | | |
506 | 540 | | |
| |||
524 | 558 | | |
525 | 559 | | |
526 | 560 | | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
527 | 575 | | |
528 | 576 | | |
529 | 577 | | |
| |||
541 | 589 | | |
542 | 590 | | |
543 | 591 | | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
544 | 596 | | |
545 | 597 | | |
546 | 598 | | |
| |||
0 commit comments