Skip to content

Conversation

@cofin
Copy link
Member

@cofin cofin commented Dec 14, 2025

Summary

Fixes test failures in CI caused by aiosqlite 0.22.0 changing its Connection class to no longer inherit from threading.Thread.

The Problem

In aiosqlite 0.22.0, the Connection class was refactored and no longer inherits from threading.Thread. This caused AttributeError when:

  • Setting the daemon attribute on the connection (line 233)
  • Calling is_alive() on tracked threads during pool shutdown (lines 402, 411)

The Solution

  • Use hasattr() to conditionally set daemon only on older aiosqlite versions
  • Use isinstance(connection, threading.Thread) before adding to tracked threads set
  • Move threading import to runtime for the isinstance check

Key Changes

  • Backward compatible with both old (Thread-based) and new (non-Thread) aiosqlite versions
  • No functional changes to connection pooling behavior
  • Pool shutdown gracefully handles absence of thread tracking

aiosqlite 0.22.0 changed the Connection class to no longer inherit from
threading.Thread. This caused AttributeError when:
- Setting daemon attribute on connection
- Calling is_alive() during pool shutdown

Changes:
- Use hasattr() check before setting daemon attribute
- Use isinstance() to only track connections that are Thread instances
- Move threading import to runtime for isinstance check
@cofin cofin force-pushed the fix/upstream-updates branch from 41470a9 to 7ad27f8 Compare December 14, 2025 18:33
@cofin cofin changed the title fix: resolve type errors in aiosqlite pool fix: handle aiosqlite 0.22.0 Connection no longer inheriting from Thread Dec 14, 2025
- aiosqlite: Add passive health checks (skip SELECT 1 for recently-used connections),
  pool warming (min_size parameter), and configurable health_check_interval.
  Remove dead thread tracking code from aiosqlite 0.22.0 compatibility fix.

- sqlite: Change journal mode from DELETE to WAL for better concurrency
  (aligning with aiosqlite async pool). Add connection recycling, passive
  health checks, and logging.

- duckdb: Wire up existing but unused _is_connection_alive() method for
  passive health checks on long-idle connections. Add configurable
  health_check_interval parameter.
Clean up dead code - all 6 adapter configs had unused logger declarations
@cofin cofin merged commit f6f0a75 into main Dec 14, 2025
10 checks passed
@cofin cofin deleted the fix/upstream-updates branch December 14, 2025 19:35
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.

2 participants