Skip to content

Print instructions and info on interrupt - #303

Merged
DanGould merged 1 commit into
payjoin:masterfrom
DanGould:ctrlc
Jun 27, 2024
Merged

Print instructions and info on interrupt#303
DanGould merged 1 commit into
payjoin:masterfrom
DanGould:ctrlc

Conversation

@DanGould

@DanGould DanGould commented Jun 26, 2024

Copy link
Copy Markdown
Member

Interrupting the program just killed it. Now it prints messages

  • send: "Interrupted. Call send with the same arguments to resume this session or resume to resume all sessions.""
  • receive: "Interrupted. Call the resume command to resume all sessions."
  • resume: "Interrupted. Call the resume command to resume all sessions."

Before this change, resume even printed "All sessions completed" on interrupt.


I'm not the most pleased with the resume interrupt but it's late and I didn't want to lose the train of thought while I had it. It was hastily put together with an LLM and will need a good review before it's even eligible for merge. Would be nice for 0.0.7-alpha but it's low priority, I just wanted to get a draft working before my mind switched off of it.

@DanGould
DanGould marked this pull request as draft June 26, 2024 04:48
Comment thread payjoin-cli/src/app/v2.rs Outdated
@DanGould
DanGould marked this pull request as ready for review June 27, 2024 16:00
@DanGould
DanGould requested a review from spacebear21 June 27, 2024 16:03
Comment thread payjoin-cli/src/app/v2.rs Outdated
Ok(())
}
_ = interrupt.changed() => {
Err(anyhow!("Interrupted. Call `send` with the same arguments to resume this session or `resume` to resume all sessions."))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is for the receiver.

Suggested change
Err(anyhow!("Interrupted. Call `send` with the same arguments to resume this session or `resume` to resume all sessions."))
Err(anyhow!("Interrupted. Call the `resume` command to resume all sessions."))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

🙏

Comment thread payjoin-cli/src/app/v2.rs Outdated
Ok(())
}
_ = interrupt.changed() => {
Err(anyhow!("Interrupted. Call `send` with the same arguments to resume this session or `resume` to resume all sessions."))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why not println! instead of returning an error (like in resume)? As it stands it prints: "Error: Interrupted. Call send with the same arguments to resume this session or resume to resume all sessions."

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Doh! I was wondering why this looked so wrong. An interrupt isn't an error, it's just a different Ok path. Adopted.

Print an informative message on how to proceed when any `send`,
`receive`, or `resume` command is interrupted.

Use `tokio::signal::ctrl_c` to do this without introducing any new
dependency.
@DanGould

Copy link
Copy Markdown
Member Author

I've adopted your suggestions and also refactored spawn_payjoin_receiver to only tokio::select! over the interruptable block. The diff should be much easier to read

@DanGould
DanGould requested a review from spacebear21 June 27, 2024 17:06

@spacebear21 spacebear21 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

tACK

@DanGould
DanGould merged commit c94a8f2 into payjoin:master Jun 27, 2024
@DanGould
DanGould deleted the ctrlc branch June 27, 2024 17:32
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.

2 participants