Conversation
Contributor
Author
|
CI failures are unrelated to these changes. |
ncoop57
commented
Jul 17, 2026
| "outputs": [], | ||
| "source": [ | ||
| "async def _outer(): return run_sync(_double(4))\n", | ||
| "test_eq(asyncio.run(_outer()), 8)" |
Contributor
Author
There was a problem hiding this comment.
This failed for me since jupyter/solveit is already running in an event loop
ncoop57
marked this pull request as ready for review
July 17, 2026 13:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces async debouncing and throttling utilities to
fastcore.aio:Debounce— A class that coalesces bursts of calls to a function into a single invocation, firingwaitseconds after calls stop (with optionalmax_waitcap). Supportsleadingandtrailingedge modes, cross-thread safety viacall_soon_threadsafe, and works as a descriptor on methods.debounced(wait, max_wait=None, leading=False, trailing=True)— A decorator wrappingDebouncefor easy use on functions and methods.throttled(wait, leading=False)— A convenience decorator equivalent todebounced(wait, max_wait=wait), firing at most once perwaitseconds.Details
Debounce.__call__schedules a background task that waits for the quiet period to elapse before firing the latest call.flush()runs any pending call immediately;cancel()discards it.__get__/__set_name__), each instance gets its ownDebouncebound topartial(self.f, obj).call_soon_threadsafe.Notes
patchnow works on callable objects too, not just functions (needed so it composes withDebounce). Objects have no__code__, so the co_qualname stamping from #821 is skipped for them. To fastaudit, a debounced method therefore shows up under its plain function name, notClass.name, so class-style allowlist entries won't match it.Minimal repro: