Skip to content

Commit

Permalink
close pipes on process end, to force flush
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Moffat committed Oct 24, 2016
1 parent bb9810b commit 12bfe9b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 1.2 -

* bugfix where pipes passed into `_out` or `_err` were not flushed on process end [#252](https://github.com/amoffat/sh/pull/252)
* deprecated `with sh.args(**kwargs)` in favor of `sh2 = sh(**kwargs)`
* made `sh.pushd` thread safe
* added `.kill_group()` and `.signal_group()` methods for better process control [#237](https://github.com/amoffat/sh/pull/237)
Expand Down
6 changes: 6 additions & 0 deletions sh.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
from functools import partial
import inspect
import tempfile
import stat
import glob as glob_module
import ast
from contextlib import contextmanager
Expand Down Expand Up @@ -2243,6 +2244,11 @@ def finish():
if hasattr(handler, "flush"):
handler.flush()

if hasattr(handler, "fileno"):
fd_stat = os.fstat(handler.fileno())
if stat.S_ISFIFO(fd_stat.st_mode):
handler.close()

return process, finish

def get_callback_chunk_consumer(handler, encoding, decode_errors):
Expand Down

0 comments on commit 12bfe9b

Please sign in to comment.