Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e16b48e

Browse filesBrowse files
author
Kartik Raj
committed
Add fixes
1 parent 7580f32 commit e16b48e
Copy full SHA for e16b48e

File tree

Expand file treeCollapse file tree

11 files changed

+59
-25
lines changed
Filter options
Expand file treeCollapse file tree

11 files changed

+59
-25
lines changed

‎.gitignore

Copy file name to clipboardExpand all lines: .gitignore
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ log.log
55
**/node_modules
66
*.pyc
77
*.vsix
8+
envVars.txt
89
**/.vscode/.ropeproject/**
910
**/testFiles/**/.cache/**
1011
*.noseids

‎build/webpack/webpack.extension.config.js

Copy file name to clipboardExpand all lines: build/webpack/webpack.extension.config.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ const config = {
1919
target: 'node',
2020
entry: {
2121
extension: './src/client/extension.ts',
22+
'shellExec.worker': './src/client/common/process/worker/shellExec.worker.ts',
23+
'plainExec.worker': './src/client/common/process/worker/plainExec.worker.ts',
24+
'registryKeys.worker': 'src/client/pythonEnvironments/common/registryKeys.worker.ts',
25+
'registryValues.worker': 'src/client/pythonEnvironments/common/registryValues.worker.ts',
2226
},
2327
devtool: 'source-map',
2428
node: {
@@ -51,6 +55,10 @@ const config = {
5155
},
5256
],
5357
},
58+
{
59+
test: /\.worker\.js$/,
60+
use: { loader: 'worker-loader' },
61+
},
5462
],
5563
},
5664
externals: [

‎package-lock.json

Copy file name to clipboardExpand all lines: package-lock.json
+31-20Lines changed: 31 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Copy file name to clipboardExpand all lines: package.json
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,6 +1659,7 @@
16591659
"typescript": "4.5.5",
16601660
"uuid": "^8.3.2",
16611661
"webpack": "^5.76.0",
1662+
"worker-loader": "^3.0.8",
16621663
"webpack-bundle-analyzer": "^4.5.0",
16631664
"webpack-cli": "^4.9.2",
16641665
"webpack-fix-default-import-plugin": "^1.0.3",

‎src/client/common/process/worker/main.ts

Copy file name to clipboardExpand all lines: src/client/common/process/worker/main.ts
+14-1Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,25 @@
22
// Licensed under the MIT License.
33

44
import { Worker } from 'worker_threads';
5-
import { traceError } from '../../../logging';
5+
import { traceVerbose, traceError } from '../../../logging/index';
66

7+
/**
8+
* Executes a worker file. Make sure to declare the worker file as a entry in the webpack config.
9+
* @param workerFileName Filename of the worker file to execute, it has to end with ".worker.js" for webpack to bundle it.
10+
* @param workerData Arguments to the worker file.
11+
* @returns
12+
*/
713
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
814
export async function executeWorkerFile(workerFileName: string, workerData: any): Promise<any> {
15+
if (!workerFileName.endsWith('.worker.js')) {
16+
throw new Error('Worker file must end with ".worker.js" for webpack to bundle webworkers');
17+
}
918
return new Promise((resolve, reject) => {
19+
traceVerbose(`Starting worker ${workerFileName} with data ${JSON.stringify(workerData)}`);
1020
const worker = new Worker(workerFileName, { workerData });
21+
traceVerbose(`Started worker ${workerFileName}`);
1122
worker.on('message', (msg: { err: Error; res: unknown }) => {
23+
traceVerbose(`Worker ${workerFileName} sent message ${JSON.stringify(msg)}`);
1224
if (msg.err) {
1325
reject(msg.err);
1426
}
@@ -19,6 +31,7 @@ export async function executeWorkerFile(workerFileName: string, workerData: any)
1931
reject(ex);
2032
});
2133
worker.on('exit', (code) => {
34+
traceVerbose(`Worker ${workerFileName} exited with code ${code}`);
2235
if (code !== 0) {
2336
reject(new Error(`Worker ${workerFileName} stopped with exit code ${code}`));
2437
}

‎src/client/common/process/worker/rawProcessApiWrapper.ts

Copy file name to clipboardExpand all lines: src/client/common/process/worker/rawProcessApiWrapper.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { executeWorkerFile } from './main';
77
import { ExecutionResult, ShellOptions } from './types';
88

99
export function workerShellExec(command: string, options: ShellOptions): Promise<ExecutionResult<string>> {
10-
return executeWorkerFile(path.join(__dirname, 'shellExecWorker.js'), {
10+
return executeWorkerFile(path.join(__dirname, 'shellExec.worker.js'), {
1111
command,
1212
options,
1313
});
@@ -18,7 +18,7 @@ export function workerPlainExec(
1818
args: string[],
1919
options: SpawnOptions = {},
2020
): Promise<ExecutionResult<string>> {
21-
return executeWorkerFile(path.join(__dirname, 'plainExecWorker.js'), {
21+
return executeWorkerFile(path.join(__dirname, 'plainExec.worker.js'), {
2222
file,
2323
args,
2424
options,

‎src/client/pythonEnvironments/common/windowsRegistry.ts

Copy file name to clipboardExpand all lines: src/client/pythonEnvironments/common/windowsRegistry.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export async function readRegistryValues(options: Options, useWorkerThreads: boo
3939
});
4040
return deferred.promise;
4141
}
42-
return executeWorkerFile(path.join(__dirname, 'registryValuesWorker.js'), options);
42+
return executeWorkerFile(path.join(__dirname, 'registryValues.worker.js'), options);
4343
}
4444

4545
export async function readRegistryKeys(options: Options, useWorkerThreads: boolean): Promise<IRegistryKey[]> {
@@ -56,5 +56,5 @@ export async function readRegistryKeys(options: Options, useWorkerThreads: boole
5656
});
5757
return deferred.promise;
5858
}
59-
return executeWorkerFile(path.join(__dirname, 'registryKeysWorker.js'), options);
59+
return executeWorkerFile(path.join(__dirname, 'registryKeys.worker.js'), options);
6060
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.