Close Output Module in Followstream #97
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I recently noted that the closing body and html tags were not being applied in HTML output from followstream. Looking into it further, I noted that when output modules are instantiated from within the decoder's
__init__
, they are not closed by decode.py becauseout
now differs fromdecoder.out
within decode'smain
.I explored calling
self.out.close()
from the decoder's__del__
, but by the time this function is called (at the end of decode.py's main) the filehandle (decoder.out.fh
=out.fh
) has been closed, so colorout's attempt to write the closing tags generates a ValueError (I/O operation on closed file).Another approach would be to test each decoder at the end of
main
to see if its output decoder is equal to the default out and close it appropriately, but I didn't want to make this change unilaterally.