()
| 245 | } |
| 246 | |
| 247 | private handleCrash(): void { |
| 248 | this.ready = false; |
| 249 | this.crashCount++; |
| 250 | |
| 251 | if (this.pendingRequest) { |
| 252 | this.pendingRequest.reject(new Error('Worker crashed')); |
| 253 | this.pendingRequest = null; |
| 254 | } |
| 255 | |
| 256 | if (this.crashCount < this.maxCrashes) { |
| 257 | logger.warn(`Python worker crashed (${this.crashCount}/${this.maxCrashes}), restarting...`); |
| 258 | this.startWorker().catch((err) => { |
| 259 | logger.error(`Failed to restart worker: ${err}`); |
| 260 | }); |
| 261 | } else { |
| 262 | logger.error(`Python worker crashed ${this.maxCrashes} times, marking as dead`); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | isReady(): boolean { |
| 267 | return this.ready; |
no test coverage detected