diff options
Diffstat (limited to 'packages/taler-wallet-core/src/shepherd.ts')
-rw-r--r-- | packages/taler-wallet-core/src/shepherd.ts | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/packages/taler-wallet-core/src/shepherd.ts b/packages/taler-wallet-core/src/shepherd.ts index 5e2d23fd9..3b160d97f 100644 --- a/packages/taler-wallet-core/src/shepherd.ts +++ b/packages/taler-wallet-core/src/shepherd.ts @@ -149,6 +149,7 @@ export interface TaskScheduler { reload(): Promise<void>; getActiveTasks(): TaskIdStr[]; isIdle(): boolean; + shutdown(): Promise<void>; } export class TaskSchedulerImpl implements TaskScheduler { @@ -176,6 +177,14 @@ export class TaskSchedulerImpl implements TaskScheduler { return [...this.sheps.keys()]; } + async shutdown(): Promise<void> { + const tasksIds = [...this.sheps.keys()]; + logger.info(`Stopping task shepherd.`); + for (const taskId of tasksIds) { + this.stopShepherdTask(taskId); + } + } + async ensureRunning(): Promise<void> { if (this.isRunning) { return; @@ -193,7 +202,7 @@ export class TaskSchedulerImpl implements TaskScheduler { logger.error(`err: ${e}`); }) .then(() => { - logger.info("done running task loop"); + logger.trace("done running task loop"); this.isRunning = false; }); } @@ -212,11 +221,11 @@ export class TaskSchedulerImpl implements TaskScheduler { } private async run(): Promise<void> { - logger.info("Running task loop."); - logger.info(`sheps: ${this.sheps.size}`); + logger.trace("Running task loop."); + logger.trace(`sheps: ${this.sheps.size}`); while (true) { if (this.ws.stopped) { - logger.info("Breaking out of task loop (wallet stopped)."); + logger.trace("Breaking out of task loop (wallet stopped)."); break; } @@ -228,7 +237,7 @@ export class TaskSchedulerImpl implements TaskScheduler { await this.iterCond.wait(); } - logger.info("Done with task loop."); + logger.trace("Done with task loop."); } startShepherdTask(taskId: TaskIdStr): void { @@ -360,11 +369,11 @@ export class TaskSchedulerImpl implements TaskScheduler { }; } if (info.cts.token.isCancelled) { - logger.info("task cancelled, not processing result"); + logger.trace("task cancelled, not processing result"); return; } if (this.ws.stopped) { - logger.info("wallet stopped, not processing result"); + logger.trace("wallet stopped, not processing result"); return; } wex.oc.observe({ |