Skip to content

Commit 78255d4

Browse files
authored
Simplify lock(DOWNLOAD_LOCK) (#136)
1 parent 20e0990 commit 78255d4

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/Downloads.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,12 @@ function request(
303303
throw :: Bool = true,
304304
downloader :: Union{Downloader, Nothing} = nothing,
305305
) :: Union{Response, RequestError}
306-
lock(DOWNLOAD_LOCK) do
307-
yield() # let other downloads finish
308-
downloader isa Downloader && return
309-
while true
306+
if downloader === nothing
307+
lock(DOWNLOAD_LOCK) do
310308
downloader = DOWNLOADER[]
311-
downloader isa Downloader && return
312-
DOWNLOADER[] = Downloader()
309+
if downloader === nothing
310+
downloader = DOWNLOADER[] = Downloader()
311+
end
313312
end
314313
end
315314
local response

0 commit comments

Comments
 (0)