You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found an issue that redirect_stdout fails to restore to the prior stdout when the function is calling in multiple tasks.
Background
I use Julia as the back-end server for an online website, providing bioinformatics classification service for biologists. At the back-end, the Julia server runs classification tasks with multi-threads, and collect stdout and stderr of each task in a separate log file.
However, I found some tasks are failed to output to correct log file, and sometimes Base.stdout and Base.stderr are changed to some log files.
After digging into the problem, I found redirect_stdxxx sets the global stdxxx, and is not thread save. Is is possible to create a thread safe version of those functions?
Environment
Tested in Julia 1.6.1 and 1.7.0-rc1. Version info are shown below.
Julia Version 1.7.0-rc1
Commit 9eade6195e (2021-09-12 06:45 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i9-9940X CPU @ 3.30GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-12.0.1 (ORCJIT, skylake-avx512)
A small case
outfile =tempname()
outio =open(outfile, "a+")
f() =redirect_stdout(outio) doprintln(stderr, "start redirect stdout")
sleep(20)
println(stderr, "stop redirect stdout")
endschedule(@taskf())
@showstdout# IOStream(<file /tmp/jl_k82o7M>)sleep(20)
@showstdout# Base.TTY(RawFD(13) open, 0 bytes waiting)schedule(@taskf())
sleep(2)
schedule(@taskf())
@showstdoutsleep(20)
@showstdout# should be TTY, but is IOStream# IOStream(<file /tmp/jl_k82o7M>)
The text was updated successfully, but these errors were encountered:
cihga39871
changed the title
redirect_stdxxx works unexpected with Tasks or multi-threads. Feature request in multi-threadsredirect_stdxxx works unexpected with Tasks or multi-threads
Oct 6, 2021
I found an issue that
redirect_stdout
fails to restore to the prior stdout when the function is calling in multiple tasks.Background
I use Julia as the back-end server for an online website, providing bioinformatics classification service for biologists. At the back-end, the Julia server runs classification tasks with multi-threads, and collect stdout and stderr of each task in a separate log file.
However, I found some tasks are failed to output to correct log file, and sometimes Base.stdout and Base.stderr are changed to some log files.
After digging into the problem, I found
redirect_stdxxx
sets the global stdxxx, and is not thread save. Is is possible to create a thread safe version of those functions?Environment
Tested in Julia 1.6.1 and 1.7.0-rc1. Version info are shown below.
A small case
The text was updated successfully, but these errors were encountered: