Skip to content

Commit

Permalink
(Try to) close suprocess file handles after we are done with it
Browse files Browse the repository at this point in the history
This should fix pyinvoke#665
  • Loading branch information
voidus committed Mar 25, 2023
1 parent e956312 commit 0cea56f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions invoke/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,11 @@ def returncode(self) -> Optional[int]:
return self.process.returncode

def stop(self) -> None:
for fd in ['stdout', 'stderr', 'stdin']:
try:
getattr(self.process, fd).close()
except:
pass # We tried 🤷
# If we opened a PTY for child communications, make sure to close() it,
# otherwise long-running Invoke-using processes exhaust their file
# descriptors eventually.
Expand Down

0 comments on commit 0cea56f

Please sign in to comment.