mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Close session after execute. (#2677)
This commit is contained in:
parent
89ec39f629
commit
de7e27c92c
@ -58,6 +58,7 @@ def execute(q):
|
|||||||
This method also retries a few times in the case of stale connections.
|
This method also retries a few times in the case of stale connections.
|
||||||
"""
|
"""
|
||||||
import sqlalchemy.exc
|
import sqlalchemy.exc
|
||||||
|
try:
|
||||||
for _ in range(0, RETRIES):
|
for _ in range(0, RETRIES):
|
||||||
try:
|
try:
|
||||||
return [
|
return [
|
||||||
@ -66,6 +67,8 @@ def execute(q):
|
|||||||
if row is not None]
|
if row is not None]
|
||||||
except sqlalchemy.exc.SQLAlchemyError as e:
|
except sqlalchemy.exc.SQLAlchemyError as e:
|
||||||
log_error(e, retry_wait=QUERY_RETRY_WAIT, rollback=True)
|
log_error(e, retry_wait=QUERY_RETRY_WAIT, rollback=True)
|
||||||
|
finally:
|
||||||
|
Session().close()
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user