mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Close session after execute. (#2677)
This commit is contained in:
parent
a81a8c2bdf
commit
74f284d2d7
@ -58,14 +58,17 @@ 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
|
||||||
for _ in range(0, RETRIES):
|
try:
|
||||||
try:
|
for _ in range(0, RETRIES):
|
||||||
return [
|
try:
|
||||||
row for row in
|
return [
|
||||||
(row.to_native() for row in q)
|
row for row in
|
||||||
if row is not None]
|
(row.to_native() for row in q)
|
||||||
except sqlalchemy.exc.SQLAlchemyError as e:
|
if row is not None]
|
||||||
log_error(e, retry_wait=QUERY_RETRY_WAIT, rollback=True)
|
except sqlalchemy.exc.SQLAlchemyError as e:
|
||||||
|
log_error(e, retry_wait=QUERY_RETRY_WAIT, rollback=True)
|
||||||
|
finally:
|
||||||
|
Session().close()
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user