diff --git a/src/gridtk/cli.py b/src/gridtk/cli.py index bb185be..2b7cf1f 100644 --- a/src/gridtk/cli.py +++ b/src/gridtk/cli.py @@ -60,6 +60,13 @@ def cli(ctx, database, logs_dir): ctx.meta["job_manager"] = JobManager(database=database, logs_dir=logs_dir) +@cli.result_callback() +def process_result(result, **kwargs): + """Delete the job manager from the context.""" + ctx = click.get_current_context() + del ctx.meta["job_manager"] + + @cli.command( epilog="""\b Example: diff --git a/src/gridtk/manager.py b/src/gridtk/manager.py index 1130238..1200c58 100644 --- a/src/gridtk/manager.py +++ b/src/gridtk/manager.py @@ -135,6 +135,7 @@ def update_jobs(self) -> None: for grid_id, job in jobs_by_grid_id.items(): if grid_id in job_statuses: job.update(job_statuses[grid_id]) + self.session.flush() def list_jobs( self, @@ -200,3 +201,4 @@ def __del__(self): Path(self.database).unlink() if self.logs_dir.exists() and len(os.listdir(self.logs_dir)) == 0: shutil.rmtree(self.logs_dir) + self.engine.dispose()