@@ -108,6 +108,7 @@ class NativePythonFinderImpl implements NativePythonFinder {
108108 private readonly connection : rpc . MessageConnection ;
109109 private readonly pool : WorkerPool < NativePythonEnvironmentKind | Uri [ ] | undefined , NativeInfo [ ] > ;
110110 private cache : Map < string , NativeInfo [ ] > = new Map ( ) ;
111+ private readonly startDisposables : Disposable [ ] = [ ] ;
111112
112113 constructor (
113114 private readonly outputChannel : LogOutputChannel ,
@@ -192,6 +193,8 @@ class NativePythonFinderImpl implements NativePythonFinder {
192193 }
193194
194195 public dispose ( ) {
196+ this . pool . stop ( ) ;
197+ this . startDisposables . forEach ( ( d ) => d . dispose ( ) ) ;
195198 this . connection . dispose ( ) ;
196199 }
197200
@@ -221,14 +224,13 @@ class NativePythonFinderImpl implements NativePythonFinder {
221224 // we have got the exit event.
222225 const readable = new PassThrough ( ) ;
223226 const writable = new PassThrough ( ) ;
224- const disposables : Disposable [ ] = [ ] ;
225227 try {
226228 const proc = spawnProcess ( this . toolPath , [ 'server' ] , { env : process . env , stdio : 'pipe' } ) ;
227229 proc . stdout . pipe ( readable , { end : false } ) ;
228230 proc . stderr . on ( 'data' , ( data ) => this . outputChannel . error ( `[pet] ${ data . toString ( ) } ` ) ) ;
229231 writable . pipe ( proc . stdin , { end : false } ) ;
230232
231- disposables . push ( {
233+ this . startDisposables . push ( {
232234 dispose : ( ) => {
233235 try {
234236 if ( proc . exitCode === null ) {
@@ -246,7 +248,7 @@ class NativePythonFinderImpl implements NativePythonFinder {
246248 new rpc . StreamMessageReader ( readable ) ,
247249 new rpc . StreamMessageWriter ( writable ) ,
248250 ) ;
249- disposables . push (
251+ this . startDisposables . push (
250252 connection ,
251253 new Disposable ( ( ) => {
252254 readable . end ( ) ;
@@ -276,7 +278,7 @@ class NativePythonFinderImpl implements NativePythonFinder {
276278 } ) ,
277279 connection . onNotification ( 'telemetry' , ( data ) => this . outputChannel . info ( '[pet] Telemetry: ' , data ) ) ,
278280 connection . onClose ( ( ) => {
279- disposables . forEach ( ( d ) => d . dispose ( ) ) ;
281+ this . startDisposables . forEach ( ( d ) => d . dispose ( ) ) ;
280282 } ) ,
281283 ) ;
282284
0 commit comments