Skip to content

fix(client): sleep between polls in the blocking poll helper - #1583

Open
cplieger wants to merge 1 commit into
moghtech:mainfrom
cplieger:fix/client-polling-busy-loop-and-doc-ref
Open

fix(client): sleep between polls in the blocking poll helper#1583
cplieger wants to merge 1 commit into
moghtech:mainfrom
cplieger:fix/client-polling-busy-loop-and-doc-ref

Conversation

@cplieger

Copy link
Copy Markdown
Contributor

Two small defects in the execute-then-poll helpers, found while working out why an Action's second execute on one resource failed with Resource is busy. (It was my bug: I should have used execute_and_poll. These two turned up on the way.)

1. The blocking poll helper busy-loops

poll_update_until_complete under #[cfg(feature = "blocking")] has no delay in its loop, so it re-issues GetUpdate as fast as the network allows for the whole duration of the execution. For a Stack deploy that is minutes of hot looping against Core.

The async variant already does tokio::time::sleep(Duration::from_millis(500)). This adds the matching std::thread::sleep, same interval. Duration is already imported.

2. A doc comment points at a function that does not exist

client/core/ts/src/lib.ts, on execute:

To have the call only return when the task finishes, use [execute_and_poll_until_complete].

The exported function is execute_and_poll. The surrounding note is genuinely useful, which is why the dangling name is worth fixing: it is the pointer a reader follows when they hit exactly the problem the note describes.

Verification

cargo check -p komodo_client --features blocking clean, cargo fmt leaves it untouched. The TS change is a comment.

Two small defects in the execute-then-poll helpers.

The blocking poll_update_until_complete had no delay in its loop, so it
re-issued GetUpdate as fast as the network allowed for the entire duration of
the execution. The async variant already sleeps 500ms; this matches it.

The execute doc comment pointed readers at [execute_and_poll_until_complete],
which does not exist. The function is execute_and_poll.
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