@async read(stdin, Char)

I want to listen on the stdin but my module stucks loading. I see kinda the problem. Is there a way around?

module T
       t() = @async while true read(stdin, Char) end
       t()
end

Are you precompiling the module? If so, it might be breaking the precompilation as it uses stdin for RPC. Maybe lazily start the task listening to stdin? Another way is to start only if it’s not precompiling (see, e.g., Requires.jl for how to do it).

Just like the example above. I’m using Juno and tried it in the REPL.

Have you tried it in the REPL?

How is this done?

Juno does some weird stuff for communicating over the REPL, so this breaks everything basically :wink:
But your code breaks a normal non-Juno REPL too, because you’re stealing repl inputs. I’d recommend either running that code without a REPL or putting it into a @sync block.

How can I put a while true into a @sync-block?

It’s impossible to say how exactly you should do that without knowing what you’re doing with the inputs.

That’s true :slight_smile:
I’m calling the julia script from C# and redirecting the input and output stream. I want to listen on both sites the whole time in order to communicate.

This worked for me. Thank you :+1: