Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle ValueError when child wants to reset stderr but it is closed. (p…
…antsbuild#6932) ### Problem After forking, when the child wants to reset `sys.stderr` as part of setting up the `ExceptionSink`, if `sys.stderr` was closed, it would except and crash. ### Solution Wrap the line in `try:except`, and log it as a warning. However, I have a doubt: The line in question happens in {{post_fork_child}} after a call to {{daemonize}}, and fails because {{sys.stderr}} is closed. So, given that we are considering that case as "non-fatal" (hence turning the exception into a warning), would it make sense to instead write something like: ```python if not sys.stderr.closed: ExceptionSink.reset_interactive_output_stream(sys.stderr) else: logger = logging.getLogger(__name__) logger.warn("Cannot reset output stream - sys.stderr is closed") ``` The difference is small, but if the answer is no it means that I'm missing something. ### Result One less hard-to-find crash, hopefully.
- Loading branch information