Skip to content

Instantly share code, notes, and snippets.

@pfitzseb
Created April 30, 2018 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfitzseb/c3b7e4b30283413b375c7d7b128b4b0e to your computer and use it in GitHub Desktop.
Save pfitzseb/c3b7e4b30283413b375c7d7b128b4b0e to your computer and use it in GitHub Desktop.
julia> function async_eval(code)
sleep(2)
# hide prompt
print(stdout, "\e[1K\r")
# write code
printstyled(stdout, "julia> ", bold = true, color=:green)
print(stdout, code)
# eval code
println(stdout)
print(stdout, include_string(Main, code)) # should have some error handling
print(stdout, "\n\n")
# restore prompt
printstyled(stdout, "julia> ", bold = true, color=:green)
end
async_eval (generic function with 1 method)
julia> @async async_eval("sleep(1); 1+2")
Task (runnable) @0x00007f0c4b433490
julia> sleep(1); 1+2
3
julia>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment