Skip to content

Commit 2451dd3

Browse files
Attempt to dbg restart and run all cells
1 parent dc67c4e commit 2451dd3

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

kernel/src/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import { IKernel, IKernelSpecs } from '@jupyterlite/kernel';
44
import { EmbeddedKernel } from './kernel';
55
import WelcomePanel from './panel';
66
import { ServiceContainer } from './services/ServiceContainer';
7+
import { DeviceService } from './services/DeviceService';
8+
9+
// Variable for saving the DeviceService instance so we can restore it if kernel is restarted
10+
var devService: DeviceService | null = null;
711

812
// Kernel plugin for the embedded kernel
913
const kernelPlugin: JupyterLiteServerPlugin<void> = {
@@ -39,11 +43,14 @@ const kernelPlugin: JupyterLiteServerPlugin<void> = {
3943
},
4044
},
4145
create: async (options: IKernel.IOptions): Promise<IKernel> => {
42-
46+
4347
console.log("CREATED NEW EMBEDDED KERNEL...")
44-
const serviceContainer = new ServiceContainer()
48+
const serviceContainer = new ServiceContainer(devService);
4549
await serviceContainer.init();
4650

51+
// Save the DeviceService instance so we can restore it if kernel is restarted
52+
devService = serviceContainer.deviceService;
53+
4754
const welcomePanel = new WelcomePanel(serviceContainer);
4855
document.body.appendChild(welcomePanel.getElement());
4956
const kernel = new EmbeddedKernel(options, serviceContainer);

kernel/src/services/ServiceContainer.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ export class ServiceContainer {
1010
private _firmwareService: FirmwareService;
1111
private _flashService: FlashService;
1212

13-
constructor() {
14-
this._deviceService = new DeviceService();
13+
constructor(devService?: DeviceService | null) {
14+
// If a DeviceService instance is passed (and is not null), use it; otherwise, create a new one.
15+
this._deviceService = devService || new DeviceService();
1516
this._consoleService = new ConsoleService(this._deviceService);
1617
this._firmwareService = new FirmwareService(this._deviceService);
1718

0 commit comments

Comments
 (0)