Skip to content

Commit

Permalink
bindings/python: rename Wrapper._clear()
Browse files Browse the repository at this point in the history
Allow future.pimpl._clear() to be called from other parts
of the binding by dropping an underscore from its prefix.

The _clear method has some extra protections to ensure the C
destructor is only called once, thus future.pimpl._clear()
is the preferred way to explicitly dispose of a future.

This is a prereq for explicit cleanup of futures in the
job() class.

Originally proposed in #2553.
  • Loading branch information
SteVwonder authored and garlick committed Dec 2, 2019
1 parent da7ebab commit 16d4a80
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/bindings/python/flux/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def __getattr__(self, name):
setattr(self, name, new_method)
return new_method

def __clear(self):
def _clear(self):
# avoid recursion
if hasattr(self, "_handle") and self._handle is not None:
handle = self._handle
Expand Down Expand Up @@ -354,14 +354,14 @@ def handle(self, h):
)
)
if self._handle is not None:
self.__clear()
self._clear()
self._handle = h

def __del__(self):
self.__clear()
self._clear()

def __enter__(self):
return self

def __exit__(self, type_arg, value, unused):
self.__clear()
self._clear()

0 comments on commit 16d4a80

Please sign in to comment.