Yes, this is definitely possible, but there are a few tricky parts to get right.
To fix this, you can run the child process and listen to its output on a separate thread. Then, send those outputs through a channel and print them in your main thread before you call readline() again. Here's a working example using Python as the child REPL: