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

feat: Slow down successive (same) exercise execution via throttle #818

Merged
merged 13 commits into from
Sep 4, 2024

Conversation

schloerke
Copy link
Collaborator

Originally from #814 . I was not able to apply code suggestions (weird!), so I made a new branch within the learnr repo.

This adds a new option tutorial.exercise.debounce to slow down successive exercise evaluations.

I've noticed that you can overwhelm a server that hosts a learnr tutorial by repeatedly clicking "Run Code" very quickly in an exercise chunk. On the Linux server that I'm using, this causes learnr to run a new R instance for each evaluation, amounting to hundreds or thousands of instances, depending on how quick you can click and how fast the server can execute and tear down again the R instances.

My fix introduces the use of debounce() when the option is active.

Use options("tutorial.exercise.debounce" = 1000) in a setup chunk of an Rmarkdown document to enable a debounce of 1 sec. The default value is 0, which keeps the behavior currently implemented in learnr (i.e. no debounce).

This is my first contribution here, I'm not quite sure if I've updated the documentation at the correct spot.

PR task list:

  • Update NEWS
  • Update documentation with devtools::document()

R/exercise.R Outdated Show resolved Hide resolved
R/exercise.R Outdated Show resolved Hide resolved
R/exercise.R Outdated Show resolved Hide resolved
@schloerke schloerke force-pushed the feat-debounce-exercise-execution branch from 916a00e to 61ff563 Compare September 4, 2024 18:21
@schloerke schloerke changed the title feat: Slow down successive exercise execution via debounce feat: Slow down successive (same) exercise execution via throttle Sep 4, 2024
@schloerke schloerke merged commit a644d2d into main Sep 4, 2024
11 checks passed
@schloerke schloerke deleted the feat-debounce-exercise-execution branch September 4, 2024 18:26
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.

3 participants