Skip to content

Commit

Permalink
Close plugins during garbage collection
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Prescod committed Aug 1, 2022
1 parent 5e5747b commit 9aa8f55
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion snowfakery/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ def _register_for_continuation(cls):


class PluginResultIterator(PluginResult):
closed = False

def __init__(self, repeat):
self.repeat = repeat

Expand Down Expand Up @@ -353,7 +355,12 @@ def restart(self):

def close(self):
"Subclasses should implement this if they need to clean up resources"
pass # pragma: no cover
pass

def __del__(self):
if not self.closed:
self.close()
self.close = True


class PluginOption:
Expand Down

0 comments on commit 9aa8f55

Please sign in to comment.