Skip to content

Allow async execution and cancelling - Session.signal Session.execute_async#12

Open
dbernheisel wants to merge 1 commit intomainfrom
dbern/cancel-job
Open

Allow async execution and cancelling - Session.signal Session.execute_async#12
dbernheisel wants to merge 1 commit intomainfrom
dbern/cancel-job

Conversation

@dbernheisel
Copy link
Copy Markdown
Collaborator

@dbernheisel dbernheisel commented Apr 27, 2026

Following on #11 but with a different API and closer to real bash mannerisms.

  • Add Bash.Session.signal(..., signal) to give more control on how to kill the bash session. If passing in the session, it's going to signal to the current execution. If passing in a reference, it will cancel that execution. If it hasn't executed yet (eg, there are multiple chained execute_async and it hasn't gotten there yet, it will pop from the queue and have a synthetic exit.
  • Breaking Adjust Bash.execute_async to return a set of references for tracking execution, before it would simply return :ok but now it's {:ok, info}. This allows the user to cancel that execution.
  • Multiple Bash.Session.execute_async on a session will queue up the executions serially. This somewhat acts like merging Bash scripts, but they're chunked and individually await-able.
  • Not breaking, but Bash.execute now uses execute_async but awaits upon it.
  • When cancelling an in-progress Bash session, depending on the signal, it will go from SIGTERM -> grace period -> SIGKILL. If a bash script has a trap, this is important so it has time to execute the trap. Folks will likely want this by default, though they're still welcome to signal a kill and skip the trap (just like in real bash).

@lostbean would you mind reviewing and testing this to see if this meets your needs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant