Fix SQLite threading bugs (#553)
Fixes two SQLite threading bugs that caused intermittent test failures with errors like "cannot commit transaction - SQL statements in progress" and "System database accessed before DBOS was launched". ## Changes - Pass `engine_kwargs` to `create_engine` in `SQLiteSystemDatabase._create_engine`, filtering PostgreSQL-specific `connect_args` (`application_name`, `connect_timeout`) - Reorder `_destroy()` to join background threads before closing database connections - Add 10-second timeout to thread joins with warning log if threads don't exit - Set `_run_background_processes = False` before joining threads to signal graceful shutdown ## Testing - Added `test_sqlite_engine_kwargs_passed` to verify `engine_kwargs` are passed through - Added `test_sqlite_filters_postgres_connect_args` to verify PostgreSQL-specific args are filtered - Added `test_destroy_closes_db_before_joining_threads` to reproduce the race condition ## References - https://github.com/pydantic/pydantic-ai/issues/3934 --------- Co-authored-by: Peter Kraft <petereliaskraft@gmail.com>
B
Ben Drucker committed
646009e29f443177075e2674a18e59436aa59f9c
Parent: 598e19c
Committed by GitHub <noreply@github.com>
on 1/11/2026, 8:42:05 PM