Skip to content

Commit

Permalink
bindings/python: destroy future after use
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
andre-merzky committed Nov 22, 2019
1 parent 6a8d3be commit 99687aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/bindings/python/flux/future.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 3 additions & 1 deletion src/bindings/python/flux/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 99687aa

Please sign in to comment.