Skip to content

Commit

Permalink
bindings/python: explicitly clear futures
Browse files Browse the repository at this point in the history
Problem: job.submit() and job.wait() both seem to
leak futures.

The futures in these "synchronous" methods go out
of scope and thus should be automatically destroyed,
but due to a circular reference alluded to by
@SteVwonder in #2549, they persist.

As a workaround, explicitly call _clear() on the
futures in these methods.

Credit goes to @andre-merzky for proposing the first
version of this patch in #2553, based on a suggestion
by @grondo, with changes proposed by @SteVwonder.
Group effort!

Fixes #2549.
  • Loading branch information
garlick committed Dec 2, 2019
1 parent 16d4a80 commit 011e9ea
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/bindings/python/flux/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ 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)
# pylint: disable=protected-access
future.pimpl._clear()
return jid


def wait_async(flux_handle, jobid=lib.FLUX_JOBID_ANY):
Expand All @@ -78,4 +81,7 @@ def wait_get_status(future):

def wait(flux_handle, jobid=lib.FLUX_JOBID_ANY):
future = wait_async(flux_handle, jobid)
return wait_get_status(future)
status = wait_get_status(future)
# pylint: disable=protected-access
future.pimpl._clear()
return status

0 comments on commit 011e9ea

Please sign in to comment.