mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 15:47:12 +00:00
Override connect method in RecorderPool (#148490)
This commit is contained in:
parent
0729b3a2f1
commit
ed4a23d104
@ -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.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user