Skip to content

Commit 6f5b4c8

Browse files
authored
Merge pull request #48 from julia-vscode/sp/close-msg-queues
close channels when corresponding pipe is closed
2 parents b347fbf + a21d5eb commit 6f5b4c8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/core.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ function Base.run(x::JSONRPCEndpoint)
106106
else
107107
Base.display_error(stderr, err, bt)
108108
end
109+
finally
110+
close(x.out_msg_queue)
109111
end
110112

111113
x.read_task = @async try
@@ -143,6 +145,8 @@ function Base.run(x::JSONRPCEndpoint)
143145
else
144146
Base.display_error(stderr, err, bt)
145147
end
148+
finally
149+
close(x.in_msg_queue)
146150
end
147151

148152
x.status = :running
@@ -233,8 +237,8 @@ function Base.close(endpoint::JSONRPCEndpoint)
233237
flush(endpoint)
234238

235239
endpoint.status = :closed
236-
close(endpoint.in_msg_queue)
237-
close(endpoint.out_msg_queue)
240+
isopen(endpoint.in_msg_queue) && close(endpoint.in_msg_queue)
241+
isopen(endpoint.out_msg_queue) && close(endpoint.out_msg_queue)
238242

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

0 commit comments

Comments
 (0)