Skip to content

Commit 07e3fd7

Browse files
committed
integrate time out
1 parent 84ac7ee commit 07e3fd7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/error_handling.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,24 @@ end
5959
handle_error(e, q) = rethrow(e)
6060

6161
function handle_error(e::NotInstalledError, q)
62+
time_out_time = 50 #tempted to make this global, but only makes sense if we allow to set it.
6263
println("Library ", e.library, " is not installed but can load format: ", q)
6364
println("should we install ", e.library, " for you? (y/n):")
64-
while true
65+
start_time = time()
66+
while time() - start_time < time_out_time # give user time_out_time seconds to react, then time out
6567
input = lowercase(chomp(strip(readline(STDIN))))
6668
if input == "y"
6769
info(string("Start installing ", e.library, "..."))
6870
Pkg.add(string(e.library))
6971
return false # don't continue
7072
elseif input == "n"
7173
info(string("Not installing ", e.library))
72-
return true
74+
return true # User does not install, continue going through errors.
7375
else
7476
println("$input is not a valid choice. Try typing y or n")
7577
end
7678
end
79+
info(string("Time out after $time_out_time seconds! Not installing ", e.library))
7780
true # User does not install, continue going through errors.
7881
end
7982

0 commit comments

Comments
 (0)