From 99687aa9976a3d3f3a2f018c4e23a561ad05d1e6 Mon Sep 17 00:00:00 2001 From: Andre Merzky Date: Fri, 22 Nov 2019 15:22:14 +0100 Subject: [PATCH] bindings/python: destroy future after use Following a suggestion by @grondo, the `submit_get_id`-future sees delayed / no garbage collection and causes a significant slowdown due to apparent limits in the future layer. This commit adds explicit destruction after future completion, thus avoiding that issue. --- src/bindings/python/flux/future.py | 3 +++ src/bindings/python/flux/job.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bindings/python/flux/future.py b/src/bindings/python/flux/future.py index 446a2d6b7519..c1158741a71f 100644 --- a/src/bindings/python/flux/future.py +++ b/src/bindings/python/flux/future.py @@ -115,6 +115,9 @@ def then(self, callback, arg=None, timeout=-1.0): # For example `f.rpc('topic').then(cb).wait_for(-1) return self + def destroy(self): + self.pimpl.destroy() + def reset(self): self.pimpl.reset() diff --git a/src/bindings/python/flux/job.py b/src/bindings/python/flux/job.py index f3149b54e5d0..8c2a0bc3beb0 100644 --- a/src/bindings/python/flux/job.py +++ b/src/bindings/python/flux/job.py @@ -51,4 +51,6 @@ def submit_get_id(future): def submit(flux_handle, jobspec, priority=lib.FLUX_JOB_PRIORITY_DEFAULT, flags=0): future = submit_async(flux_handle, jobspec, priority, flags) - return submit_get_id(future) + jid = submit_get_id(future) + future.destroy() + return jid