Skip to content

Commit f6094bf

Browse files
Always close precompile server (#1209)
1 parent 320e4e5 commit f6094bf

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/precompile.jl

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,25 @@ try
2222
server = HTTP.serve!("0.0.0.0", _port; verbose = -1, listenany=true, sslconfig=sslconfig) do req
2323
HTTP.Response(200, ["Content-Encoding" => "gzip"], gzip_data("dummy response"))
2424
end
25-
# listenany allows changing port if that one is already in use, so check the actual port
26-
_port = HTTP.port(server)
27-
url = "https://localhost:$_port"
28-
29-
env = ["JULIA_NO_VERIFY_HOSTS" => "localhost",
30-
"JULIA_SSL_NO_VERIFY_HOSTS" => nothing,
31-
"JULIA_ALWAYS_VERIFY_HOSTS" => nothing]
32-
withenv(env...) do
33-
@compile_workload begin
34-
HTTP.get(url);
25+
try
26+
# listenany allows changing port if that one is already in use, so check the actual port
27+
_port = HTTP.port(server)
28+
url = "https://localhost:$_port"
29+
30+
env = ["JULIA_NO_VERIFY_HOSTS" => "localhost",
31+
"JULIA_SSL_NO_VERIFY_HOSTS" => nothing,
32+
"JULIA_ALWAYS_VERIFY_HOSTS" => nothing]
33+
34+
withenv(env...) do
35+
@compile_workload begin
36+
HTTP.get(url);
37+
end
3538
end
39+
finally
40+
HTTP.forceclose(server)
41+
yield() # needed on 1.9 to avoid some issue where it seems a task doesn't stop before serialization
42+
server = nothing
3643
end
37-
38-
HTTP.forceclose(server)
39-
yield() # needed on 1.9 to avoid some issue where it seems a task doesn't stop before serialization
40-
server = nothing
4144
end
4245
catch e
4346
@info "Ignoring an error that occurred during the precompilation workload" exception=(e, catch_backtrace())

0 commit comments

Comments
 (0)