Files
synapse/tests
Matthew Hodgson c25e9cdbb3 ⏺ Phase 7: Async Primitive Cleanup — Complete
1 new file + additions to 1 existing file, 16 new tests, all passing, mypy clean, no regressions.

  synapse/util/async_helpers.py — New native async utility functions:

  ┌──────────────────────────┬─────────────────────────────┬────────────────────────────┐
  │     Twisted Original     │      Native Equivalent      │        Description         │
  ├──────────────────────────┼─────────────────────────────┼────────────────────────────┤
  │ yieldable_gather_results │ native_gather_results       │ asyncio.gather wrapper     │
  ├──────────────────────────┼─────────────────────────────┼────────────────────────────┤
  │ concurrently_execute     │ native_concurrently_execute │ asyncio.Semaphore + gather │
  ├──────────────────────────┼─────────────────────────────┼────────────────────────────┤
  │ timeout_deferred         │ native_timeout              │ asyncio.wait_for wrapper   │
  ├──────────────────────────┼─────────────────────────────┼────────────────────────────┤
  │ stop_cancellation        │ native_stop_cancellation    │ asyncio.shield wrapper     │
  ├──────────────────────────┼─────────────────────────────┼────────────────────────────┤
  │ AwakenableSleeper        │ NativeAwakenableSleeper     │ asyncio.Event + wait_for   │
  ├──────────────────────────┼─────────────────────────────┼────────────────────────────┤
  │ DeferredEvent            │ NativeEvent                 │ asyncio.Event wrapper      │
  └──────────────────────────┴─────────────────────────────┴────────────────────────────┘

  synapse/util/caches/future_cache.py — FutureCache:
  - asyncio-native equivalent of DeferredCache
  - Two-layer architecture: _pending (in-flight futures) + _completed (LRU dict)
  - Uses ObservableFuture for multiple observers of the same pending entry
  - Invalidation callbacks on both layers
  - Max entries with eviction of oldest completed entries
  - Failed futures are NOT cached (same behavior as DeferredCache)
  - No make_deferred_yieldable() needed — futures are directly awaitable

  ---
  Running totals across Phases 0-7:
  - 10 new files, ~3200 lines of asyncio-native implementation
  - 144 tests all passing
  - All mypy clean
  - Existing 4462-test suite unaffected
2026-03-21 15:29:43 +00:00
..