On Wednesday, June 1, 2016, Joshua Jones < [email protected]> wrote:
> >>> 1. I've read (here and elsewhere) that Julia does an implicit block >>> while waiting for data. Is there a workaround? >>> >>> Do the blocking read asynchronously in a task. For network I/O (but not >> file), `read` will only block at the task level. To end the read, `close` >> the socket from another task. >> > > Only a call to @async eof(conn) works as an asynchronous task; I'm not > sure how that's going to help, except in the REPL. Any other attempt to > read remotely is a segmentation fault that destroys the worker. > > *Example (test function)* > @everywhere readSL(conn) = begin > while true > eof(conn) > tmp = read(conn.buffer, UInt8, 520) > end > end > > > > Test call > julia> remotecall(6, readSL, conn); > > julia> > signal (11): Segmentation fault > uv_read_start at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown > line) > start_reading at stream.jl:850 > wait_readnb at stream.jl:373 > eof at stream.jl:96 > readSL at none:4 > jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so > (unknown > line) > jl_f_apply at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so (unknown > line) > anonymous at multi.jl:920 > run_work_thunk at multi.jl:661 > run_work_thunk at multi.jl:670 > jlcall_run_work_thunk_21322 at (unknown line) > jl_apply_generic at /usr/bin/../lib/x86_64-linux-gnu/julia/libjulia.so > (unknown > line) > anonymous at task.jl:58 > unknown function (ip: 0x7f1d162898cc) > unknown function (ip: (nil)) > Worker 6 terminated. > ERROR (unhandled task failure): EOFError: read end of file > in read at stream.jl:929 > in message_handler_loop at multi.jl:878 > in process_tcp_streams at multi.jl:867 > in anonymous at task.jl:63 > > Am I doing something fundamentally wrong here? > Yes: using multiprocess parallelism instead of tasks. '@everywhere' executes code on other processes that do not share the same address space as the head process and cannot access the same socket. See the section on Tasks in the manual. (though it probably shouldn't segfault, please file a big about that)
