forked from aws/aws-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Flush stdout and stderr on each write when debugging (aws#843)
* Introduce StreamWriter to wrap output streams. Fix aws#835 * Fix typo
- Loading branch information
1 parent
8f4b180
commit c849e3c
Showing
14 changed files
with
396 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
""" | ||
This class acts like a wrapper around output streams to provide any flexibility with output we need | ||
""" | ||
|
||
|
||
class StreamWriter(object): | ||
|
||
def __init__(self, stream, auto_flush=False): | ||
""" | ||
Instatiates new StreamWriter to the specified stream | ||
Parameters | ||
---------- | ||
stream io.RawIOBase | ||
Stream to wrap | ||
auto_flush bool | ||
Whether to autoflush the stream upon writing | ||
""" | ||
self._stream = stream | ||
self._auto_flush = auto_flush | ||
|
||
def write(self, output): | ||
""" | ||
Writes specified text to the underlying stream | ||
Parameters | ||
---------- | ||
output bytes-like object | ||
Bytes to write | ||
""" | ||
self._stream.write(output) | ||
|
||
if self._auto_flush: | ||
self._stream.flush() | ||
|
||
def flush(self): | ||
self._stream.flush() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.