Skip to content

Commit

Permalink
handle race in chunked response handling
Browse files Browse the repository at this point in the history
handle condition where output channel is closed already before the check and wait to detect it starts.
  • Loading branch information
tanmaykm committed Oct 31, 2021
1 parent c5dc1a3 commit 80aabed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ keywords = ["Swagger", "OpenApi", "REST"]
license = "MIT"
desc = "Swagger (OpenAPI) helper and code generator for Julia"
authors = ["Tanmay Mohapatra <[email protected]>"]
version = "0.3.1"
version = "0.3.2"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
3 changes: 3 additions & 0 deletions src/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,18 @@ function do_request(ctx::Ctx, stream::Bool=false; stream_to::Union{Channel,Nothi
end
end
@async begin
interrupted = false
while isopen(stream_to)
try
wait(stream_to)
yield()
catch ex
isa(ex, InvalidStateException) || rethrow(ex)
interrupted = true
istaskdone(download_task) || schedule(download_task, InterruptException(), error=true)
end
end
interrupted || istaskdone(download_task) || schedule(download_task, InterruptException(), error=true)
end
end
else
Expand Down

0 comments on commit 80aabed

Please sign in to comment.