How to synchronize puts
output?
#227
Answered
by
ioquatix
postmodern
asked this question in
Q&A
-
I've noticed that if I have a lot of async sub-tasks which pass data to a shared callback, which then prints the data using Examplerequire 'async'
def test(&block)
Async do |task|
task.async do
loop do
block.call("foooooooooooooooooooooooo")
sleep(0.1)
end
end
task.async do
loop do
block.call("baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar")
sleep(0.1)
end
end
end
end
test do |word|
puts word
end
How do I prevent this from happening? |
Beta Was this translation helpful? Give feedback.
Answered by
ioquatix
Apr 14, 2023
Replies: 1 comment 2 replies
-
IIRC, this should be fixed in the latest version of CRuby. What version did you test on? |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
postmodern
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
IIRC, this should be fixed in the latest version of CRuby. What version did you test on?