Skip to content

fix: key pending tasks by event loop#8875

Merged
dmadisetti merged 2 commits intomainfrom
dm/async-cache
Mar 26, 2026
Merged

fix: key pending tasks by event loop#8875
dmadisetti merged 2 commits intomainfrom
dm/async-cache

Conversation

@dmadisetti
Copy link
Copy Markdown
Collaborator

📝 Summary

closes #8866

Isolates task loop by the active event loop, isolating competing processes from trying to eval another loop's task.

Copilot AI review requested due to automatic review settings March 25, 2026 22:44
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Mar 25, 2026 10:50pm

Request Review

@dmadisetti dmadisetti added the bug Something isn't working label Mar 25, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a cross-event-loop task deduplication bug in @cache / @mo.persistent_cache for async functions by scoping “pending executions” to the currently running event loop, preventing sessions on different threads/loops from awaiting each other’s tasks (GH-8866).

Changes:

  • Key _cache_call_async._pending_executions by (cache instance, event loop) instead of only by instance to avoid cross-loop task reuse.
  • Add a regression test that simulates a stale pending future from a different loop and asserts it is not touched/awaited.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
marimo/_save/save.py Scopes async cache pending-task deduplication to the active event loop and updates cleanup logic accordingly.
tests/_save/test_cache.py Adds regression coverage for “pending task attached to a different loop” failures in app/run mode scenarios.

@dmadisetti dmadisetti merged commit 4e6c709 into main Mar 26, 2026
48 of 61 checks passed
@dmadisetti dmadisetti deleted the dm/async-cache branch March 26, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: @mo.persistent_cache on async functions crashes in marimo run with "attached to a different loop"

3 participants