betodealmeida closed pull request #5759: Bug: fixing async syntax for python 3.7
URL: https://github.com/apache/incubator-superset/pull/5759
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/db_engine_specs.py b/superset/db_engine_specs.py
index 13eb69502b..2ce7db06bf 100644
--- a/superset/db_engine_specs.py
+++ b/superset/db_engine_specs.py
@@ -370,7 +370,7 @@ def get_configuration_for_impersonation(cls, uri, 
impersonate_user, username):
         return {}
 
     @classmethod
-    def execute(cls, cursor, query, async=False):
+    def execute(cls, cursor, query, **kwargs):
         if cls.arraysize:
             cursor.arraysize = cls.arraysize
         cursor.execute(query)
@@ -1276,8 +1276,9 @@ def get_configuration_for_impersonation(cls, uri, 
impersonate_user, username):
         return configuration
 
     @staticmethod
-    def execute(cursor, query, async=False):
-        cursor.execute(query, async=async)
+    def execute(cursor, query, async_=False):
+        kwargs = {'async': async_}
+        cursor.execute(query, **kwargs)
 
 
 class MssqlEngineSpec(BaseEngineSpec):
diff --git a/superset/sql_lab.py b/superset/sql_lab.py
index a659653d37..4612b4e0ec 100644
--- a/superset/sql_lab.py
+++ b/superset/sql_lab.py
@@ -172,7 +172,7 @@ def handle_error(msg):
         cursor = conn.cursor()
         logging.info('Running query: \n{}'.format(executed_sql))
         logging.info(query.executed_sql)
-        db_engine_spec.execute(cursor, query.executed_sql, async=True)
+        db_engine_spec.execute(cursor, query.executed_sql, async_=True)
         logging.info('Handling cursor')
         db_engine_spec.handle_cursor(cursor, query, session)
         logging.info('Fetching data: {}'.format(query.to_dict()))
diff --git a/tests/celery_tests.py b/tests/celery_tests.py
index 71adb2df43..243aacef45 100644
--- a/tests/celery_tests.py
+++ b/tests/celery_tests.py
@@ -123,14 +123,14 @@ def tearDownClass(cls):
         )
 
     def run_sql(self, db_id, sql, client_id, cta='false', tmp_table='tmp',
-                async='false'):
+                async_='false'):
         self.login()
         resp = self.client.post(
             '/superset/sql_json/',
             data=dict(
                 database_id=db_id,
                 sql=sql,
-                async=async,
+                runAsync=async_,
                 select_as_cta=cta,
                 tmp_table_name=tmp_table,
                 client_id=client_id,
@@ -183,7 +183,7 @@ def test_run_async_query(self):
         eng = main_db.get_sqla_engine()
         sql_where = "SELECT name FROM ab_role WHERE name='Admin'"
         result = self.run_sql(
-            main_db.id, sql_where, '4', async='true', tmp_table='tmp_async_1',
+            main_db.id, sql_where, '4', async_='true', tmp_table='tmp_async_1',
             cta='true')
         assert result['query']['state'] in (
             QueryStatus.PENDING, QueryStatus.RUNNING, QueryStatus.SUCCESS)
@@ -211,7 +211,7 @@ def test_run_async_query_with_lower_limit(self):
         eng = main_db.get_sqla_engine()
         sql_where = "SELECT name FROM ab_role WHERE name='Alpha' LIMIT 1"
         result = self.run_sql(
-            main_db.id, sql_where, '5', async='true', tmp_table='tmp_async_2',
+            main_db.id, sql_where, '5', async_='true', tmp_table='tmp_async_2',
             cta='true')
         assert result['query']['state'] in (
             QueryStatus.PENDING, QueryStatus.RUNNING, QueryStatus.SUCCESS)


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to