Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sigint #56

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/LAMMPS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a task? Can't we just catch the InterruptException?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'll have to look into this in more detail. For my toy-example, interupting the lammps instance seems to actually work without any modifications to the code. However, when I try to interupt my real simulation, it doesn't work.

I don't know why that would be the case.

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

"""
Expand Down
Loading