Skip to content

Commit dd4069f

Browse files
Soft error the precompile workload (#1205)
* soft error precompile workload * Update precompile.jl * Update precompile.jl
1 parent c3bcd19 commit dd4069f

File tree

1 file changed

+34
-30
lines changed

1 file changed

+34
-30
lines changed

src/precompile.jl

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,44 @@
11
using PrecompileTools: @setup_workload, @compile_workload
22

3-
@setup_workload begin
4-
# These need to be safe to call here and bake into the pkgimage, i.e. called twice.
5-
Connections.__init__()
6-
MultiPartParsing.__init__()
7-
Parsers.__init__()
3+
try
4+
@setup_workload begin
5+
# These need to be safe to call here and bake into the pkgimage, i.e. called twice.
6+
Connections.__init__()
7+
MultiPartParsing.__init__()
8+
Parsers.__init__()
89

9-
# Doesn't seem to be needed here, and might not be safe to call twice (here and during runtime)
10-
# ConnectionRequest.__init__()
10+
# Doesn't seem to be needed here, and might not be safe to call twice (here and during runtime)
11+
# ConnectionRequest.__init__()
1112

12-
gzip_data(data::String) = read(GzipCompressorStream(IOBuffer(data)))
13+
gzip_data(data::String) = read(GzipCompressorStream(IOBuffer(data)))
1314

14-
# random port in the dynamic/private range (49152–65535) which are are
15-
# least likely to be used by well-known services
16-
_port = 57813
15+
# random port in the dynamic/private range (49152–65535) which are are
16+
# least likely to be used by well-known services
17+
_port = 57813
1718

18-
cert, key = joinpath.(@__DIR__, "../test", "resources", ("cert.pem", "key.pem"))
19-
sslconfig = MbedTLS.SSLConfig(cert, key)
19+
cert, key = joinpath.(@__DIR__, "../test", "resources", ("cert.pem", "key.pem"))
20+
sslconfig = MbedTLS.SSLConfig(cert, key)
2021

21-
server = HTTP.serve!("0.0.0.0", _port; verbose = -1, listenany=true, sslconfig=sslconfig) do req
22-
HTTP.Response(200, ["Content-Encoding" => "gzip"], gzip_data("dummy response"))
23-
end
24-
# listenany allows changing port if that one is already in use, so check the actual port
25-
_port = HTTP.port(server)
26-
url = "https://localhost:$_port"
27-
28-
env = ["JULIA_NO_VERIFY_HOSTS" => "localhost",
29-
"JULIA_SSL_NO_VERIFY_HOSTS" => nothing,
30-
"JULIA_ALWAYS_VERIFY_HOSTS" => nothing]
31-
withenv(env...) do
32-
@compile_workload begin
33-
HTTP.get(url);
22+
server = HTTP.serve!("0.0.0.0", _port; verbose = -1, listenany=true, sslconfig=sslconfig) do req
23+
HTTP.Response(200, ["Content-Encoding" => "gzip"], gzip_data("dummy response"))
24+
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);
35+
end
3436
end
35-
end
3637

37-
HTTP.forceclose(server)
38-
yield() # needed on 1.9 to avoid some issue where it seems a task doesn't stop before serialization
39-
server = nothing
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
41+
end
42+
catch e
43+
@info "Ignoring an error that occurred during the precompilation workload" exception=(e, catch_backtrace())
4044
end

0 commit comments

Comments
 (0)