ashb commented on a change in pull request #5162: [AIRFLOW-4358] Speed up
test_jobs by not running tasks
URL: https://github.com/apache/airflow/pull/5162#discussion_r279092065
##########
File path: airflow/utils/db.py
##########
@@ -51,21 +51,20 @@ def provide_session(func):
database transaction, you pass it to the function, if not this wrapper
will create one and close it for you.
"""
+
+ func_params = func.__code__.co_varnames
+ arg_session_index = func_params.index('session') if 'session' in
func_params else None
+
@wraps(func)
def wrapper(*args, **kwargs):
- arg_session = 'session'
-
- func_params = func.__code__.co_varnames
- session_in_args = arg_session in func_params and \
- func_params.index(arg_session) < len(args)
- session_in_kwargs = arg_session in kwargs
+ session_in_args = arg_session_index is not None and arg_session_index
< len(args)
+ session_in_kwargs = 'session' in kwargs
if session_in_kwargs or session_in_args:
return func(*args, **kwargs)
- else:
- with create_session() as session:
- kwargs[arg_session] = session
- return func(*args, **kwargs)
+
+ with create_session() as session:
+ return func(*args, session=session, **kwargs)
Review comment:
Oh whoops. this change was me messing around in debugging. I should remove
this as it is unrelated to the test speed up
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services