Skip to content

docs(memory-bank): Describe the async concurrency stack - #2563

Merged
schloerke merged 13 commits into
jat255/2549-clientdata-output-contextvarfrom
schloerke/2508-memory-bank
Oct 15, 2026
Merged

schloerke merged 13 commits into
jat255/2549-clientdata-output-contextvarfrom
schloerke/2508-memory-bank

Conversation

@schloerke

Copy link
Copy Markdown
Collaborator

Stacked on #2559. Updates the memory bank so contributor docs describe the async concurrency stack (#2549, #2545, #2546, #2520, #2547, #2548, #2525, #2552, #2559) instead of the global reactive.lock() model it replaces.

Changes

  • reactiveInternals.md: the flush loop and lock sections are replaced. New sections cover rounds (request_round() via call_soon in a fresh context, non-waiting starts, rerun instead of nesting), cycles and the busy count, run_once_when_idle(), reactive.flush() / run_until_idle() semantics, async calcs and effects interleaving, destroy-time cancellation, and the deprecated no-op reactive.lock(). Pitfalls are rewritten.
  • sessionMessaging.md: the message loop holds no lock. update messages go through run_once_when_idle(), and dispatch messages run as their own tasks. "The flush cycle" becomes "Cycles and the output flush": one message per cycle, sent even when empty; queues reset before the send is awaited; the "recalculating" yield (fix(session): Send each output's progress message before it renders #2525); and the per-task output-name ContextVar (fix(session): Track the rendering output per task for clientdata.output_*() #2559). The session-end section and pitfalls are updated.
  • otel.md: reactive_update is a per-session cycle span. It starts when the busy count goes 0→1, and it ends at idle or at session end. The doc covers its parents and children, the start_otel_span() / use_otel_span() helpers, and how test_otel_reactive_update.py tests it.
  • bookmarking.md: a new "Restore gate" section (fix(bookmark): Run async on_restore callbacks before the session's effects #2548), and the callback timing now refers to cycles instead of flushes.
  • ciAndTooling.md: the playwright-windows job and PR-checks gate, PLAYWRIGHT_INSTALL_ARGS, the pytest.ini timeout and --strict-markers settings, and why -p no:rerunfailures silently drops tests.
  • playwrightTesting.md: the Windows-specific tests, how the busy-indicator timing test works, and the async/ and express-session-start test changes.
  • New concurrencyTesting.md: how to write tests in the style of test_concurrency.py. It covers the Client drivers, wait_until with its 10 s limit, asyncio.Events instead of sleep durations for ordering, state waits plus settle() for negative assertions, duck-typed session mocks, MockTime, and releasing tasks stranded on dead event loops. architecture.md links to it.

Review notes

Writing these docs turned up a few code leftovers. This PR doesn't change any of them:

  • A comment in invalidate_later() still says the round's reactive_update span has no parent. That span now belongs to the session's cycle.
  • Shiny no longer calls detached_otel_context() (shiny/otel/_core.py), so it could be removed.
  • uploadEnd sets its input in the middle of a cycle instead of through run_once_when_idle(), unlike update messages. This matches R. The docs list it as a pitfall.

Verification

  • Each claim was checked against the code on this branch.
  • Every file.md#anchor link in memory-bank/ resolves.

@schloerke
schloerke added this pull request to stack #2550 October 15, 2026 02:54
@schloerke
schloerke force-pushed the schloerke/2508-memory-bank branch from c0859ae to 9db5645 Compare October 15, 2026 15:35
@schloerke
schloerke merged commit c3899c0 into main Oct 15, 2026
176 checks passed
@schloerke
schloerke deleted the schloerke/2508-memory-bank branch October 15, 2026 15:49
@jat255 jat255 mentioned this pull request Oct 15, 2026
25 of 33 tasks
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