-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
output of println get all mixed up from coroutines #10615
Comments
This commit - #10521 - a few hours back has a solution for |
Judging by |
Is this fix on the 0.4 branch or 0.3? I’m on 0.3.5 and my code is not going to run unchanged on 0.4 I think (due to changes in syntax for Dict etc.) I don’t want to migrate to 0.4 at this point. Also I’ve never build julia from source so… I’d prefer you do a small test 😊 Van: Amit Murthy This commit - #10521 - a few hours back has a solution for println only. Can you do a rebuild and see if it closes your issue? — |
That makes sense. Can you provide example code that causes this that runs on 0.3? |
That will be difficult I think. the code is for a recommendation system I’m writing for my company so I can’t just ‘open source’ this. The code is quite large and specific for our databases. Without the databases you won’t be able to run the code anyway. Your best bet is to write a small program that does the following: serves html page with more than 1 iframe (=> multiple simultaneous http requests) process the http request via HttpServer.jl when processing the request lookup data in a Dict with a missing key and println the stacktrace of that exception Van: Tony Kelman That makes sense. Can you provide example code that causes this that runs on 0.3? — |
On 0.3, a workaround for you would be to
backporting this feature will take sometime, given the performance regression detected due to the lock. |
In the code block, you will need to replace |
Hi, On 28 Mar 2015, at 04:50, Amit Murthy [email protected] wrote:
|
The lock is per object. Also, currently there is one thread of execution, with multiple tasks, i.e. coroutines executing concurrently. The IO subsystem, based on libuv, is event driven io. The mixed output from multiple tasks happens since the IO subsystem yields to other tasks during any IO by a task. |
Ok. Thanks for the clarification. On 28 Mar 2015, at 11:07, Amit Murthy [email protected] wrote:
|
This is a test case on recent master (fcb38c1). I'd expect the received = IOBuffer()
@sync begin
server = listen(10001)
@async begin sock = accept(server)
println("Connected")
while isopen(sock)
data = readline(sock)
write(received, data)
end
close(server)
end
# yield so we hit the server accept
yield()
busy = false
sender = connect(10001)
@async println(sender, "1234567890")
@async println(sender, "abcdefgabc")
# sleep so all our messages get through
sleep(0.1)
close(sender)
end
println("total received data:")
print(takebuf_string(received))
println("-----") I would expect to see
But instead I see
So it looks like the second message is coming before the newline from the first one. I don't see anything wrong in the locking code though. @amitmurthy any ideas? |
strangely enough, wrapping the I just replaced the pair of lk = ReentrantLock()
@async begin
lock(lk)
println(sender, "1234567890")
unlock(lk)
end
@async begin
lock(lk)
println(sender, "abcdefgabc")
unlock(lk)
end Maybe there's something weird going on where the tasks are locking different locks? Just a guess. |
334a2be#diff-ac5d350530574f3f82c860d1b963bc0a is causing this.We again need to add appropriate locks for specific IO types. cc : @JeffBezanson |
#12978 will fix this on 0.4. Closing this since we are not porting the change to 0.3 |
scenario: web page with multiple iframes => multiple http requests. Handled via HttpServer which handles multiple requests via coroutines.
When doing a simple println of stacktraces then single lines (even values from a single var!) get mixed up by the multiple coroutines. I know it's normal that different lines of the different iframes will get intermingled but not within the lines itself which makes for very hard debugging...
example:
"key not found: 5"3415785505"4
" in
getDescription in at getDescription/media/sf_Documents/julia_workspace/VMRecommender/src/Rec3.jl at :/media/sf_Documents/julia_workspace/VMRecommender/src/Rec3.jl190:
190 in
webRecFrame in at webRecFrame/media/sf_Documents/julia_workspace/VMRecommender/src/Rec3.jl at :/media/sf_Documents/julia_workspace/VMRecommender/src/Rec3.jl1501:
1501 in
anonymous in at anonymousno file at :no file266:
266 in
on_message_complete in at on_message_complete/home/steven/.julia/v0.3/HttpServer/src/HttpServer.jl at :/home/steven/.julia/v0.3/HttpServer/src/HttpServer.jl303:
303 in
on_message_complete in at on_message_complete/home/steven/.julia/v0.3/HttpServer/src/RequestParser.jl at :/home/steven/.julia/v0.3/HttpServer/src/RequestParser.jl99:MethodError99(MethodErrorResponse(,Response(,nothing(,nothing),))
)ERROR:
Response
has no method matching Response(::Nothing)in on_message_complete at /home/steven/.julia/v0.3/HttpServer/src/HttpServer.jl:305
in on_message_complete at /home/steven/.julia/v0.3/HttpServer/src/RequestParser.jl:99
ERROR:
Response
has no method matching Response(::Nothing)in on_message_complete at /home/steven/.julia/v0.3/HttpServer/src/HttpServer.jl:305
in on_message_complete at /home/steven/.julia/v0.3/HttpServer/src/RequestParser.jl:99
The text was updated successfully, but these errors were encountered: