Skip to content

Commit d1edb91

Browse files
committed
fix #7041 -- disable jupyter kernel pool for julia
1 parent 91e90c3 commit d1edb91

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

src/packages/jupyter/pool/pool.ts

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ import {
3232
} from "./pool-params";
3333
import { getAbsolutePathFromHome } from "@cocalc/jupyter/util/fs";
3434

35+
// any kernel name whose lowercase representation contains one of these strings
36+
// will never use the pool. See https://github.com/sagemathinc/cocalc/issues/7041
37+
const BLACKLIST = ["julia"];
38+
39+
function isBlacklisted(kernel: string) {
40+
const s = kernel.toLowerCase();
41+
for (const n of BLACKLIST) {
42+
if (s.includes(n)) {
43+
return true;
44+
}
45+
}
46+
return false;
47+
}
48+
3549
export type { LaunchJupyterOpts, SpawnedKernel };
3650

3751
const log = getLogger("jupyter:pool");
@@ -71,10 +85,14 @@ export default async function launchJupyterKernel(
7185
name: string, // name of the kernel
7286
opts: LaunchJupyterOpts,
7387
size_arg?: number, // min number of these in the pool
74-
timeout_s_arg?: number
88+
timeout_s_arg?: number,
7589
): Promise<SpawnedKernel> {
7690
const size: number = size_arg ?? getSize();
7791
const timeout_s: number = timeout_s_arg ?? getTimeoutS();
92+
if (isBlacklisted(name)) {
93+
log.debug(`not using kernel pool for ${name} because it is blacklisted`);
94+
return await launchJupyterKernelNoPool(name, opts);
95+
}
7896
let language;
7997
try {
8098
language = await getLanguage(name);
@@ -99,8 +117,8 @@ export default async function launchJupyterKernel(
99117
createSetenvCommand(
100118
language,
101119
"COCALC_JUPYTER_FILENAME",
102-
opts.env.COCALC_JUPYTER_FILENAME
103-
)
120+
opts.env.COCALC_JUPYTER_FILENAME,
121+
),
104122
);
105123
} catch (error) {
106124
log.error("Failed to get setenv command -- not using pool", error);
@@ -138,6 +156,15 @@ export default async function launchJupyterKernel(
138156
// pool could end up a little too big.
139157
const replenishPool = reuseInFlight(
140158
async (key: string, size_arg?: number, timeout_s_arg?: number) => {
159+
const { name, opts } = JSON.parse(key);
160+
if (isBlacklisted(name)) {
161+
log.debug(
162+
"replenishPool",
163+
key,
164+
` -- skipping since ${name} is blacklisted`,
165+
);
166+
return;
167+
}
141168
const size: number = size_arg ?? getSize();
142169
const timeout_s: number = timeout_s_arg ?? getTimeoutS();
143170
log.debug("replenishPool", key, { size, timeout_s });
@@ -149,7 +176,6 @@ const replenishPool = reuseInFlight(
149176
while (pool.length < size) {
150177
log.debug("replenishPool - creating a kernel", key);
151178
writeConfig(key);
152-
const { name, opts } = JSON.parse(key);
153179
await delay(getLaunchDelayMS());
154180
const kernel = await launchJupyterKernelNoPool(name, opts);
155181
pool.push(kernel);
@@ -162,7 +188,7 @@ const replenishPool = reuseInFlight(
162188
},
163189
{
164190
createKey: (args) => args[0],
165-
}
191+
},
166192
);
167193

168194
/*
@@ -251,7 +277,7 @@ export async function killKernel(kernel: SpawnedKernel) {
251277
} catch (error) {
252278
log.error(
253279
`Failed to delete Jupyter kernel connection file ${kernel.connectionFile}`,
254-
error
280+
error,
255281
);
256282
}
257283
}

0 commit comments

Comments
 (0)