You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/11/05 22:51:16 UTC
[GitHub] [superset] betodealmeida commented on a diff in pull request #21943: feat: refactor all `get_sqla_engine` to use contextmanager in codebase
betodealmeida commented on code in PR #21943:
URL: https://github.com/apache/superset/pull/21943#discussion_r1014735512
##########
superset/db_engine_specs/base.py:
##########
@@ -472,7 +472,10 @@ def get_engine(
schema: Optional[str] = None,
source: Optional[utils.QuerySource] = None,
) -> Engine:
- return database.get_sqla_engine(schema=schema, source=source)
+ with database.get_sqla_engine_with_context(
+ schema=schema, source=source
+ ) as engine:
+ return engine
Review Comment:
This won't work; before returning the context manager will be exited before the functions returns. It's equivalent to:
```python
with database.get_sqla_engine_with_context(...) as engine:
a = engine
return a
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org