diff --git a/src/LAMMPS.jl b/src/LAMMPS.jl index 2cb2502..a14caea 100644 --- a/src/LAMMPS.jl +++ b/src/LAMMPS.jl @@ -224,13 +224,20 @@ end ``` """ function command(lmp::LMP, cmd::Union{String, Array{String}}) - if cmd isa String - API.lammps_commands_string(lmp, cmd) - else - API.lammps_commands_list(lmp, length(cmd), cmd) - end + try + if cmd isa String + task = @async API.lammps_commands_string(lmp, cmd) + else + task = @async API.lammps_commands_list(lmp, length(cmd), cmd) + end - check(lmp) + wait(task) + check(lmp) + catch e + API.lammps_force_timeout(lmp) + check(lmp) + throw(e) + end end """