The 2-way communication seems to work ok, except when I try to read a multi-line response from the process, and I don’t know a priori how many lines it consists of.
Thanks. The first solution doesn’t work (hangs). The second one produces all the lines of the answer, and then hangs.
(Whether I run it from the REPL or from the command line).
I think you need at least one @async (see e.g., Collecting all output from shell commands - #7 by tkf), unless there is some kind of a marker from the external process that indicates the end of multi-line response. But, if you need to deal with multiple requests and responses, I don’t think there is a way to reliably relate a chunk of output lines to a response. So, using @async may not solve the actual problem.