Override connect method in RecorderPool (#148490)

This commit is contained in:
Erik Montnemery 2025-07-14 20:57:00 +02:00 committed by GitHub
parent 0729b3a2f1
commit ed4a23d104
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,6 +12,7 @@ from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.pool import ( from sqlalchemy.pool import (
ConnectionPoolEntry, ConnectionPoolEntry,
NullPool, NullPool,
PoolProxiedConnection,
SingletonThreadPool, SingletonThreadPool,
StaticPool, StaticPool,
) )
@ -119,6 +120,12 @@ class RecorderPool(SingletonThreadPool, NullPool):
) )
return NullPool._create_connection(self) # noqa: SLF001 return NullPool._create_connection(self) # noqa: SLF001
def connect(self) -> PoolProxiedConnection:
"""Return a connection from the pool."""
if threading.get_ident() in self.recorder_and_worker_thread_ids:
return super().connect()
return NullPool.connect(self)
class MutexPool(StaticPool): class MutexPool(StaticPool):
"""A pool which prevents concurrent accesses from multiple threads. """A pool which prevents concurrent accesses from multiple threads.