@@ -41,15 +41,15 @@ export class PythonDaemonExecutionServicePool implements IPythonDaemonExecutionS
4141 private readonly activatedEnvVariables ?: NodeJS . ProcessEnv ,
4242 private readonly timeoutWaitingForDaemon : number = 1_000
4343 ) {
44- if ( ! options . pythonPath ) {
44+ if ( ! options . pythonPath ) {
4545 throw new Error ( 'options.pythonPath is empty when it shoud not be' ) ;
4646 }
4747 this . pythonPath = options . pythonPath ;
4848 // Setup environment variables for the daemon.
4949 // The daemon must have access to the Python Module that'll run the daemon
5050 // & also access to a Python package used for the JSON rpc comms.
5151 const envPythonPath = `${ path . join ( EXTENSION_ROOT_DIR , 'pythonFiles' ) } ${ path . delimiter } ${ path . join ( EXTENSION_ROOT_DIR , 'pythonFiles' , 'lib' , 'python' ) } ` ;
52- this . envVariables = this . activatedEnvVariables ? { ...this . activatedEnvVariables } : { } ;
52+ this . envVariables = this . activatedEnvVariables ? { ...this . activatedEnvVariables } : { ... process . env } ;
5353 this . envVariables . PYTHONPATH = this . envVariables . PYTHONPATH ? `${ this . envVariables . PYTHONPATH } ${ path . delimiter } ${ envPythonPath } ` : envPythonPath ;
5454 this . envVariables . PYTHONUNBUFFERED = '1' ;
5555 }
@@ -65,34 +65,34 @@ export class PythonDaemonExecutionServicePool implements IPythonDaemonExecutionS
6565 noop ( ) ;
6666 }
6767 public async getInterpreterInformation ( ) : Promise < InterpreterInfomation | undefined > {
68- const msg = { args : [ 'GetPythonVersion' ] } ;
68+ const msg = { args : [ 'GetPythonVersion' ] } ;
6969 return this . wrapCall ( daemon => daemon . getInterpreterInformation ( ) , msg ) ;
7070 }
7171 public async getExecutablePath ( ) : Promise < string > {
72- const msg = { args : [ 'getExecutablePath' ] } ;
72+ const msg = { args : [ 'getExecutablePath' ] } ;
7373 return this . wrapCall ( daemon => daemon . getExecutablePath ( ) , msg ) ;
7474 }
7575 public getExecutionInfo ( args : string [ ] ) : PythonExecutionInfo {
7676 return this . pythonExecutionService . getExecutionInfo ( args ) ;
7777 }
7878 public async isModuleInstalled ( moduleName : string ) : Promise < boolean > {
79- const msg = { args : [ '-m' , moduleName ] } ;
79+ const msg = { args : [ '-m' , moduleName ] } ;
8080 return this . wrapCall ( daemon => daemon . isModuleInstalled ( moduleName ) , msg ) ;
8181 }
8282 public async exec ( args : string [ ] , options : SpawnOptions ) : Promise < ExecutionResult < string > > {
83- const msg = { args, options} ;
83+ const msg = { args, options } ;
8484 return this . wrapCall ( daemon => daemon . exec ( args , options ) , msg ) ;
8585 }
8686 public async execModule ( moduleName : string , args : string [ ] , options : SpawnOptions ) : Promise < ExecutionResult < string > > {
87- const msg = { args : [ '-m' , moduleName ] . concat ( args ) , options} ;
87+ const msg = { args : [ '-m' , moduleName ] . concat ( args ) , options } ;
8888 return this . wrapCall ( daemon => daemon . execModule ( moduleName , args , options ) , msg ) ;
8989 }
9090 public execObservable ( args : string [ ] , options : SpawnOptions ) : ObservableExecutionResult < string > {
91- const msg = { args, options} ;
91+ const msg = { args, options } ;
9292 return this . wrapObservableCall ( daemon => daemon . execObservable ( args , options ) , msg ) ;
9393 }
9494 public execModuleObservable ( moduleName : string , args : string [ ] , options : SpawnOptions ) : ObservableExecutionResult < string > {
95- const msg = { args : [ '-m' , moduleName ] . concat ( args ) , options} ;
95+ const msg = { args : [ '-m' , moduleName ] . concat ( args ) , options } ;
9696 return this . wrapObservableCall ( daemon => daemon . execModuleObservable ( moduleName , args , options ) , msg ) ;
9797 }
9898 /**
@@ -103,7 +103,7 @@ export class PythonDaemonExecutionServicePool implements IPythonDaemonExecutionS
103103 * @returns
104104 * @memberof PythonDaemonExecutionServicePool
105105 */
106- protected createConnection ( proc : ChildProcess ) {
106+ protected createConnection ( proc : ChildProcess ) {
107107 return createMessageConnection ( new StreamMessageReader ( proc . stdout ) , new StreamMessageWriter ( proc . stdin ) ) ;
108108 }
109109 @traceDecorators . error ( 'Failed to create daemon' )
@@ -131,7 +131,7 @@ export class PythonDaemonExecutionServicePool implements IPythonDaemonExecutionS
131131
132132 const cls = this . options . daemonClass ?? PythonDaemonExecutionService ;
133133 const instance = new cls ( this . pythonExecutionService , this . pythonPath , daemonProc . proc , connection ) ;
134- if ( instance instanceof PythonDaemonExecutionService ) {
134+ if ( instance instanceof PythonDaemonExecutionService ) {
135135 this . disposables . push ( instance ) ;
136136 return instance ;
137137 }
@@ -153,7 +153,7 @@ export class PythonDaemonExecutionServicePool implements IPythonDaemonExecutionS
153153 * @returns {Promise<T> }
154154 * @memberof PythonDaemonExecutionServicePool
155155 */
156- private async wrapCall < T > ( cb : ( daemon : IPythonExecutionService ) => Promise < T > , daemonLogMessage : { args : string [ ] ; options ?: SpawnOptions } ) : Promise < T > {
156+ private async wrapCall < T > ( cb : ( daemon : IPythonExecutionService ) => Promise < T > , daemonLogMessage : { args : string [ ] ; options ?: SpawnOptions } ) : Promise < T > {
157157 const daemon = await this . popDaemonFromPool ( ) ;
158158 try {
159159 // When using the daemon, log the message ourselves.
@@ -175,7 +175,7 @@ export class PythonDaemonExecutionServicePool implements IPythonDaemonExecutionS
175175 * @returns {ObservableExecutionResult<string> }
176176 * @memberof PythonDaemonExecutionServicePool
177177 */
178- private wrapObservableCall ( cb : ( daemon : IPythonExecutionService ) => ObservableExecutionResult < string > , daemonLogMessage : { args : string [ ] ; options ?: SpawnOptions } ) : ObservableExecutionResult < string > {
178+ private wrapObservableCall ( cb : ( daemon : IPythonExecutionService ) => ObservableExecutionResult < string > , daemonLogMessage : { args : string [ ] ; options ?: SpawnOptions } ) : ObservableExecutionResult < string > {
179179 const execService = this . popDaemonFromObservablePool ( ) ;
180180 // Possible the daemon returned is a standard python execution service.
181181 const daemonProc = execService instanceof PythonDaemonExecutionService ? execService . proc : undefined ;
@@ -187,19 +187,19 @@ export class PythonDaemonExecutionServicePool implements IPythonDaemonExecutionS
187187 const result = cb ( execService ) ;
188188 let completed = false ;
189189 const completeHandler = ( ) => {
190- if ( completed ) {
190+ if ( completed ) {
191191 return ;
192192 }
193193 completed = true ;
194- if ( ! daemonProc || ( ! daemonProc . killed && ProcessService . isAlive ( daemonProc . pid ) ) ) {
194+ if ( ! daemonProc || ( ! daemonProc . killed && ProcessService . isAlive ( daemonProc . pid ) ) ) {
195195 this . pushDaemonIntoPool ( 'ObservableDaemon' , execService ) ;
196196 } else {
197197 // Possible daemon is dead (explicitly killed or died due to some error).
198198 this . addDaemonService ( 'ObservableDaemon' ) . ignoreErrors ( ) ;
199199 }
200200 } ;
201201
202- if ( daemonProc ) {
202+ if ( daemonProc ) {
203203 daemonProc . on ( 'exit' , completeHandler ) ;
204204 daemonProc . on ( 'close' , completeHandler ) ;
205205 }
@@ -270,13 +270,13 @@ export class PythonDaemonExecutionServicePool implements IPythonDaemonExecutionS
270270 const testAndPushIntoPool = async ( ) => {
271271 const daemonService = ( daemon as PythonDaemonExecutionService ) ;
272272 let procIsDead = false ;
273- if ( ! daemonService . isAlive || daemonService . proc . killed || ! ProcessService . isAlive ( daemonService . proc . pid ) ) {
273+ if ( ! daemonService . isAlive || daemonService . proc . killed || ! ProcessService . isAlive ( daemonService . proc . pid ) ) {
274274 procIsDead = true ;
275275 } else {
276276 // Test sending a ping.
277277 procIsDead = await this . testDaemon ( daemonService . connection ) . then ( ( ) => false ) . catch ( ( ) => true ) ;
278278 }
279- if ( procIsDead ) {
279+ if ( procIsDead ) {
280280 // The process is dead, create a new daemon.
281281 await this . addDaemonService ( type ) ;
282282 try {
@@ -301,10 +301,10 @@ export class PythonDaemonExecutionServicePool implements IPythonDaemonExecutionS
301301 * @memberof PythonDaemonExecutionServicePool
302302 */
303303 @traceDecorators . error ( 'Pinging Daemon Failed' )
304- private async testDaemon ( connection : MessageConnection ) {
304+ private async testDaemon ( connection : MessageConnection ) {
305305 // If we don't get a reply to the ping in 5 seconds assume it will never work. Bomb out.
306306 // At this point there should be some information logged in stderr of the daemon process.
307- const fail = createDeferred < { pong : string } > ( ) ;
307+ const fail = createDeferred < { pong : string } > ( ) ;
308308 const timer = setTimeout ( ( ) => fail . reject ( new Error ( 'Timeout waiting for daemon to start' ) ) , 5_000 ) ;
309309 const request = new RequestType < { data : string } , { pong : string } , void , void > ( 'ping' ) ;
310310 // Check whether the daemon has started correctly, by sending a ping.
0 commit comments