# HG changeset patch # User Samuel Trégouët # Date 1534415504 -7200 # Node ID b3f45d96a179b814f5c7794f5108645c356fe311 # Parent 1b3d82915321de1f5957c42f604193000441f7e2 [py37] `async` is now a reserved keyword diff -r 1b3d82915321 -r b3f45d96a179 cubicweb/server/sources/datafeed.py --- a/cubicweb/server/sources/datafeed.py Wed Jul 18 13:53:00 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) diff -r 1b3d82915321 -r b3f45d96a179 cubicweb/sobjects/services.py --- a/cubicweb/sobjects/services.py Wed Jul 18 13:53:00 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']