Skip to content

Commit

Permalink
Merge pull request #48 from julia-vscode/sp/close-msg-queues
Browse files Browse the repository at this point in the history
close channels when corresponding pipe is closed
  • Loading branch information
davidanthoff authored Mar 16, 2021
2 parents b347fbf + a21d5eb commit 6f5b4c8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ function Base.run(x::JSONRPCEndpoint)
else
Base.display_error(stderr, err, bt)
end
finally
close(x.out_msg_queue)
end

x.read_task = @async try
Expand Down Expand Up @@ -143,6 +145,8 @@ function Base.run(x::JSONRPCEndpoint)
else
Base.display_error(stderr, err, bt)
end
finally
close(x.in_msg_queue)
end

x.status = :running
Expand Down Expand Up @@ -233,8 +237,8 @@ function Base.close(endpoint::JSONRPCEndpoint)
flush(endpoint)

endpoint.status = :closed
close(endpoint.in_msg_queue)
close(endpoint.out_msg_queue)
isopen(endpoint.in_msg_queue) && close(endpoint.in_msg_queue)
isopen(endpoint.out_msg_queue) && close(endpoint.out_msg_queue)

fetch(endpoint.write_task)
# TODO we would also like to close the read Task
Expand Down

0 comments on commit 6f5b4c8

Please sign in to comment.