airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject incubator-airflow git commit: [AIRFLOW-822] Close db before exception
Date Tue, 31 Jan 2017 13:34:51 GMT
Repository: incubator-airflow
Updated Branches:
  refs/heads/master a67e4390d -> 4b6c389b3


[AIRFLOW-822] Close db before exception

The basehook contains functionality to retrieve
connections from the
database. If a connection does not exist it will
throw an exception.
This exception will be thrown before the
connection to the database
is closed. Therefore the session to the db might
stay open and linger.

Closes #2038 from Fokko/airflow-822


Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/4b6c389b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/4b6c389b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/4b6c389b

Branch: refs/heads/master
Commit: 4b6c389b34d0496c8dde86d9b6e5625a53edd93d
Parents: a67e439
Author: Fokko Driesprong <fokkodriesprong@godatadriven.com>
Authored: Tue Jan 31 14:34:01 2017 +0100
Committer: Bolke de Bruin <bolke@xs4all.nl>
Committed: Tue Jan 31 14:34:20 2017 +0100

----------------------------------------------------------------------
 airflow/hooks/base_hook.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/4b6c389b/airflow/hooks/base_hook.py
----------------------------------------------------------------------
diff --git a/airflow/hooks/base_hook.py b/airflow/hooks/base_hook.py
index e640b63..f5eeb6a 100644
--- a/airflow/hooks/base_hook.py
+++ b/airflow/hooks/base_hook.py
@@ -48,11 +48,11 @@ class BaseHook(object):
             .filter(Connection.conn_id == conn_id)
             .all()
         )
+        session.expunge_all()
+        session.close()
         if not db:
             raise AirflowException(
                 "The conn_id `{0}` isn't defined".format(conn_id))
-        session.expunge_all()
-        session.close()
         return db
 
     @classmethod


Mime
View raw message