From b023618950ec886ea26139248ba7de804683a506 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 7 Aug 2018 21:52:02 +0000 Subject: [PATCH] Revert "In Python 3.7 async is a strict language keyword that can't be used for variables names - replaces occurrences with _async" This reverts commit e625861edf630ce03394bb13c9056776a4f81970. --- platypush/backend/http/__init__.py | 2 +- platypush/config/__init__.py | 4 ++-- platypush/cron/scheduler.py | 2 +- platypush/message/request/__init__.py | 2 +- platypush/procedure/__init__.py | 20 ++++++++++---------- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/platypush/backend/http/__init__.py b/platypush/backend/http/__init__.py index 9706c0635..b2fd7939a 100644 --- a/platypush/backend/http/__init__.py +++ b/platypush/backend/http/__init__.py @@ -239,7 +239,7 @@ class HttpBackend(Backend): if isinstance(msg, Request): try: - response = msg.execute(_async=False) + response = msg.execute(async=False) except PermissionError: abort(401) diff --git a/platypush/config/__init__.py b/platypush/config/__init__.py index 285c55e02..96e48ad90 100644 --- a/platypush/config/__init__.py +++ b/platypush/config/__init__.py @@ -148,10 +148,10 @@ class Config(object): self.cronjobs[cron_name] = self._config[key] elif key.startswith('procedure.'): tokens = key.split('.') - _async = True if tokens[1] == 'async' else False + async = True if tokens[1] == 'async' else False procedure_name = '.'.join(tokens[2:]) self.procedures[procedure_name] = { - 'async': _async, + 'async': async, 'actions': self._config[key] } else: diff --git a/platypush/cron/scheduler.py b/platypush/cron/scheduler.py index 2bf46d964..8b597a7ec 100644 --- a/platypush/cron/scheduler.py +++ b/platypush/cron/scheduler.py @@ -27,7 +27,7 @@ class Cronjob(Thread): context = {} for action in self.actions: - response = action.execute(_async=False, **context) + response = action.execute(async=False, **context) logger.info('Response from cronjob {}: {}'.format(self.name, response)) diff --git a/platypush/message/request/__init__.py b/platypush/message/request/__init__.py index 66ce3fcbc..5c46ceef1 100644 --- a/platypush/message/request/__init__.py +++ b/platypush/message/request/__init__.py @@ -71,7 +71,7 @@ class Request(Message): proc_name = self.action.split('.')[-1] proc_config = Config.get_procedures()[proc_name] proc = Procedure.build(name=proc_name, requests=proc_config['actions'], - _async=proc_config['async'], + async=proc_config['async'], backend=self.backend, id=self.id) return proc.execute(*args, **kwargs) diff --git a/platypush/procedure/__init__.py b/platypush/procedure/__init__.py index 2bef5b9f8..20c230038 100644 --- a/platypush/procedure/__init__.py +++ b/platypush/procedure/__init__.py @@ -11,7 +11,7 @@ logger = logging.getLogger(__name__) class Procedure(object): """ Procedure class. A procedure is a pre-configured list of requests """ - def __init__(self, name, _async, requests, backend=None): + def __init__(self, name, async, requests, backend=None): """ Params: name -- Procedure name @@ -21,7 +21,7 @@ class Procedure(object): """ self.name = name - self._async = _async + self.async = async self.requests = requests self.backend = backend @@ -30,7 +30,7 @@ class Procedure(object): @classmethod - def build(cls, name, _async, requests, backend=None, id=None, **kwargs): + def build(cls, name, async, requests, backend=None, id=None, **kwargs): reqs = [] loop_count = 0 if_count = 0 @@ -47,11 +47,11 @@ class Procedure(object): # A 'for' loop is synchronous. Declare a 'fork' loop if you # want to process the elements in the iterable in parallel - _async = True if m.group(1) == 'fork' else False + async = True if m.group(1) == 'fork' else False iterator_name = m.group(2) iterable = m.group(3) - loop = LoopProcedure.build(name=loop_name, _async=_async, + loop = LoopProcedure.build(name=loop_name, async=async, requests=request_config[key], backend=backend, id=id, iterator_name=iterator_name, @@ -87,7 +87,7 @@ class Procedure(object): request = Request.build(request_config) reqs.append(request) - return cls(name=name, _async=_async, requests=reqs, backend=backend, **kwargs) + return cls(name=name, async=async, requests=reqs, backend=backend, **kwargs) def execute(self, n_tries=1, **context): @@ -105,7 +105,7 @@ class Procedure(object): if token: request.token = token - context['async'] = self._async; context['n_tries'] = n_tries + context['async'] = self.async; context['n_tries'] = n_tries response = request.execute(**context) if not self._async: @@ -145,15 +145,15 @@ class LoopProcedure(Procedure): context = {} - def __init__(self, name, iterator_name, iterable, requests, _async=False, backend=None, **kwargs): - super(). __init__(name=name, _async=_async, requests=requests, backend=None, **kwargs) + def __init__(self, name, iterator_name, iterable, requests, async=False, backend=None, **kwargs): + super(). __init__(name=name, async=async, requests=requests, backend=None, **kwargs) self.iterator_name = iterator_name self.iterable = iterable self.requests = requests - def execute(self, _async=None, **context): + def execute(self, async=None, **context): iterable = Request.expand_value_from_context(self.iterable, **context) response = Response()