summaryrefslogtreecommitdiff
path: root/extension
diff options
context:
space:
mode:
authorNate Sesti <sestinj@gmail.com>2023-08-04 22:28:41 -0700
committerNate Sesti <sestinj@gmail.com>2023-08-04 22:28:41 -0700
commit941797359f6554ac16a2e478047aabd5cbc0404b (patch)
tree26449d355fc6919b7bd380565d641d5e1d434a91 /extension
parent2c01d8a0aa52368158763dd7eac02f2a3d5e7a36 (diff)
downloadsncontinue-941797359f6554ac16a2e478047aabd5cbc0404b.tar.gz
sncontinue-941797359f6554ac16a2e478047aabd5cbc0404b.tar.bz2
sncontinue-941797359f6554ac16a2e478047aabd5cbc0404b.zip
fix: :bug: solve EBUSY by polling
Diffstat (limited to 'extension')
-rw-r--r--extension/src/activation/environmentSetup.ts32
1 files changed, 23 insertions, 9 deletions
diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts
index 8818c949..32dfa52f 100644
--- a/extension/src/activation/environmentSetup.ts
+++ b/extension/src/activation/environmentSetup.ts
@@ -226,15 +226,29 @@ export async function startContinuePythonServer() {
// Run the executable
console.log("Starting Continue server");
- const child = spawn(destination, {
- detached: true,
- stdio: "ignore",
- });
- child.on("error", (err: any) => {
- console.error("Failed to start subprocess.", err);
- });
-
- child.unref();
+ let attempts = 0;
+ let maxAttempts = 5;
+ let delay = 1000; // Delay between each attempt in milliseconds
+
+ const spawnChild = () => {
+ const child = spawn(destination, {
+ detached: true,
+ stdio: "ignore",
+ });
+
+ child.on("error", (err: any) => {
+ if (err.code === "EBUSY" && attempts < maxAttempts) {
+ attempts++;
+ console.log(`EBUSY error caught. Retrying attempt ${attempts}...`);
+ setTimeout(spawnChild, delay);
+ } else {
+ console.error("Failed to start subprocess.", err);
+ }
+ });
+ child.unref();
+ };
+
+ spawnChild();
// Write the current version of vscode extension to a file called server_version.txt
fs.writeFileSync(serverVersionPath(), getExtensionVersion());