LGTM, thanks.
As it relates to the TREX patch, yes I will try to refactor towards using this to handle the TREX foreground server process. I guess the one change I would need to make is changing the default InteractiveShell timeout from 5 seconds to a larger number (like 20) since TREX can take a long time to start up and produce the "end_token." That could be a part of my patch though, not this patch.
Thanks.