Python can be run interactively

This commit is contained in:
Radon Rosborough 2020-12-25 12:19:09 -08:00
parent 14f7bec490
commit 938e41b1c6
2 changed files with 26 additions and 21 deletions

View File

@ -3,7 +3,8 @@ import path from "path";
import WebSocket from "ws"; import WebSocket from "ws";
import pty from "node-pty"; import pty from "node-pty";
import PQueue from "p-queue"; import pQueue from "p-queue";
const PQueue = pQueue.default;
import rpc from "vscode-jsonrpc"; import rpc from "vscode-jsonrpc";
import { v4 as getUUID } from "uuid"; import { v4 as getUUID } from "uuid";
@ -187,7 +188,6 @@ export class Session {
return; return;
} }
let msg; let msg;
n;
try { try {
msg = JSON.parse(event); msg = JSON.parse(event);
} catch (err) { } catch (err) {

View File

@ -8,6 +8,7 @@ import _ from "lodash";
import * as api from "./api.js"; import * as api from "./api.js";
import { langs } from "./langs.js"; import { langs } from "./langs.js";
import { log } from "./util.js";
const host = process.env.HOST || "localhost"; const host = process.env.HOST || "localhost";
const port = parseInt(process.env.PORT || "") || 6119; const port = parseInt(process.env.PORT || "") || 6119;
@ -55,6 +56,7 @@ app.use("/js", express.static("frontend/out"));
function addWebsocket(baseApp, httpsServer) { function addWebsocket(baseApp, httpsServer) {
const app = ws(baseApp, httpsServer).app; const app = ws(baseApp, httpsServer).app;
app.ws("/api/v1/ws", (ws, req) => { app.ws("/api/v1/ws", (ws, req) => {
try {
const lang = req.query.get("lang"); const lang = req.query.get("lang");
if (!lang) { if (!lang) {
ws.send( ws.send(
@ -75,6 +77,9 @@ function addWebsocket(baseApp, httpsServer) {
} else { } else {
new api.Session(ws, lang, console.log).setup(); new api.Session(ws, lang, console.log).setup();
} }
} catch (err) {
log.error("Unexpected error while handling websocket:", err);
}
}); });
return app; return app;
} }