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

Connect: use /v1/tasks/{id} for task polling #1088

Closed
aronatkins opened this issue Jun 27, 2024 · 0 comments · Fixed by #1089
Closed

Connect: use /v1/tasks/{id} for task polling #1088

aronatkins opened this issue Jun 27, 2024 · 0 comments · Fixed by #1089

Comments

@aronatkins
Copy link
Contributor

Use GET /__api__/v1/tasks/{id} to track task progress.

waitForTask = function(taskId, quiet = FALSE) {
start <- 0
while (TRUE) {
path <- paste0(file.path("/tasks", taskId), "?first_status=", start)
response <- GET(service, authInfo, path)
if (length(response$status) > 0) {
if (!quiet) {
messages <- unlist(response$status)
messages <- stripConnectTimestamps(messages)
# Made headers more prominent.
heading <- grepl("^# ", messages)
messages[heading] <- cli::style_bold(messages[heading])
cat(paste0(messages, "\n", collapse = ""))
}
start <- response$last_status
}
if (length(response$finished) > 0 && response$finished) {
return(response)
}
Sys.sleep(1)
}
},

Documentation:

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 a pull request may close this issue.

1 participant