Skip to content

Add concurrency tests for parallel query execution (Issue #20)#21

Merged
CollierKing merged 1 commit into
mainfrom
test/issue-20-concurrent-queries
Apr 10, 2026
Merged

Add concurrency tests for parallel query execution (Issue #20)#21
CollierKing merged 1 commit into
mainfrom
test/issue-20-concurrent-queries

Conversation

@CollierKing

Copy link
Copy Markdown
Owner

Summary

  • Adds TestParallelQueries to the Worker integration test suite with two timing-based tests
  • Proves that create_engine_from_binding() and WorkerConnection both support concurrent D1 queries via asyncio.gather()
  • Each test fires 10 unique parameterized queries sequentially then in parallel, asserting parallel time < 80% of sequential time

Key finding

SyncWorkerConnection uses pyodide.ffi.run_sync() internally, which drives the JS event loop rather than blocking it. This means asyncio.gather() genuinely interleaves D1 round-trips — the user's concern in issue #20 is not a problem in practice.

Test plan

  • test_engine_queries_are_concurrentcreate_engine_from_binding() shows speedup with asyncio.gather()
  • test_worker_connection_queries_are_concurrentWorkerConnection shows speedup with asyncio.gather()
  • All 56 Worker integration tests pass
  • Pre-commit checks pass

Closes #20

Proves that both create_engine_from_binding() and WorkerConnection
support concurrent D1 queries via asyncio.gather(). Each test fires
10 unique parameterized queries sequentially then in parallel and
asserts parallel time is < 80% of sequential time.

Key finding: SyncWorkerConnection.run_sync() drives the JS event loop
rather than blocking it, so asyncio.gather() genuinely interleaves
D1 round-trips for both connection types.
@CollierKing CollierKing merged commit 437fefa into main Apr 10, 2026
8 checks passed
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.

Async engine creation from bindings

1 participant