Skip to content

Commit

Permalink
Fix the Subprocess finalizer
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-kirienko committed Jan 22, 2024
1 parent 8a980e1 commit fc66248
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,13 @@ def alive(self) -> bool:
return self._inferior.poll() is None

def __del__(self) -> None:
if self._inferior.poll() is None:
self._inferior.kill()
try:
inf = self._inferior
except AttributeError:
pass # Ignore semi-constructed objects.
else:
if inf.poll() is None:
inf.kill()


def _read_stream(io: typing.Any) -> str:
Expand Down

0 comments on commit fc66248

Please sign in to comment.