[py37] `async` is now a reserved keyword 3.26
authorSamuel Trégouët <samuel.tregouet@logilab.fr>
Thu, 16 Aug 2018 12:31:44 +0200
branch3.26
changeset 12429 fe3ffa2fe5c3
parent 12428 744c66f41e96
child 12430 5b6f54f6033a
[py37] `async` is now a reserved keyword
cubicweb/server/sources/datafeed.py
cubicweb/sobjects/services.py
--- a/cubicweb/server/sources/datafeed.py	Wed Jul 11 09:18:57 2018 +0200
+++ b/cubicweb/server/sources/datafeed.py	Thu Aug 16 12:31:44 2018 +0200
@@ -19,6 +19,7 @@
 database
 """
 
+from warnings import warn
 from io import BytesIO
 from os.path import exists
 from datetime import datetime, timedelta
@@ -157,11 +158,11 @@
                     {'x': self.eid})
         cnx.commit()
 
-    def pull_data(self, cnx, force=False, raise_on_error=False, async=False):
+    def pull_data(self, cnx, force=False, raise_on_error=False, sync=True, **kwargs):
         """Launch synchronization of the source if needed.
 
-        If `async` is true, the method return immediatly a dictionnary containing the import log's
-        eid, and the actual synchronization is done asynchronously. If `async` is false, return some
+        If `sync` is false, the method return immediatly a dictionnary containing the import log's
+        eid, and the actual synchronization is done asynchronously. If `sync` is True, return some
         imports statistics (e.g. number of created and updated entities).
 
         This method is responsible to handle commit/rollback on the given connection.
@@ -176,10 +177,14 @@
             self.error(str(exc))
             return {}
         try:
-            if async:
+            if kwargs.get('async') is not None:
+                warn('[3.27] `async` is reserved keyword in py3.7 use `sync` param instead',
+                     DeprecationWarning)
+                sync = not kwargs['async']
+            if sync:
+                return self._pull_data(cnx, force, raise_on_error)
+            else:
                 return self._async_pull_data(cnx, force, raise_on_error)
-            else:
-                return self._pull_data(cnx, force, raise_on_error)
         finally:
             cnx.rollback()  # rollback first in case there is some dirty transaction remaining
             self.release_synchronization_lock(cnx)
--- a/cubicweb/sobjects/services.py	Wed Jul 11 09:18:57 2018 +0200
+++ b/cubicweb/sobjects/services.py	Thu Aug 16 12:31:44 2018 +0200
@@ -143,5 +143,5 @@
 
     def call(self, source_eid):
         source = self._cw.repo.source_by_eid(source_eid)
-        result = source.pull_data(self._cw, force=True, async=True)
+        result = source.pull_data(self._cw, force=True, sync=False)
         return result['import_log_eid']