diff options
| author | tpavelchak | 2019-10-18 16:34:13 +0300 |
|---|---|---|
| committer | jason | 2019-10-25 10:35:58 -0600 |
| commit | 6a827f5a77ffb3b4a7f1bd245211110d54f29d9d (patch) | |
| tree | 3a1d2f5a4b8c30e24913eabb2971815d79f24f5a | |
| parent | 3a536e184309f04a4ffe9dff446207e7267f2f99 (diff) | |
| download | eventmq-6a827f5a77ffb3b4a7f1bd245211110d54f29d9d.tar.gz eventmq-6a827f5a77ffb3b4a7f1bd245211110d54f29d9d.zip | |
Replace parameter named async to async_
| -rw-r--r-- | eventmq/client/jobs.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/eventmq/client/jobs.py b/eventmq/client/jobs.py index 9ec9a07..bd9db58 100644 --- a/eventmq/client/jobs.py +++ b/eventmq/client/jobs.py | |||
| @@ -59,7 +59,7 @@ class Job(object): | |||
| 59 | s.sendmail('me@gmail.com', [recipient,], msg.as_string()) | 59 | s.sendmail('me@gmail.com', [recipient,], msg.as_string()) |
| 60 | s.quit() | 60 | s.quit() |
| 61 | """ | 61 | """ |
| 62 | def __init__(self, broker_addr=None, queue=None, async=True, *args, | 62 | def __init__(self, broker_addr=None, queue=None, async_=True, *args, |
| 63 | **kwargs): | 63 | **kwargs): |
| 64 | """ | 64 | """ |
| 65 | Args: | 65 | Args: |
| @@ -69,20 +69,20 @@ class Job(object): | |||
| 69 | address is given then the value of the environment variable | 69 | address is given then the value of the environment variable |
| 70 | ``EMQ_BROKER_ADDR`` will be used, If that is undefined a | 70 | ``EMQ_BROKER_ADDR`` will be used, If that is undefined a |
| 71 | warning will be emitted and the job will be run synchronously. | 71 | warning will be emitted and the job will be run synchronously. |
| 72 | async (bool): If you want to run all executions of a particular job | 72 | async_ (bool): If you want to run all executions of a particular |
| 73 | synchronously but still decorate it with the job decorator you | 73 | job synchronously but still decorate it with the job decorator |
| 74 | can set this to False. This is useful for unit tests. | 74 | you can set this to False. This is useful for unit tests. |
| 75 | 75 | ||
| 76 | """ | 76 | """ |
| 77 | # conf.BROKER_ADDR isn't used because /etc/eventmq.conf is for the | 77 | # conf.BROKER_ADDR isn't used because /etc/eventmq.conf is for the |
| 78 | # daemons. | 78 | # daemons. |
| 79 | self.broker_addr = broker_addr or os.environ.get(ENV_BROKER_ADDR) | 79 | self.broker_addr = broker_addr or os.environ.get(ENV_BROKER_ADDR) |
| 80 | self.queue = queue | 80 | self.queue = queue |
| 81 | self.async = async | 81 | self.async_ = async_ |
| 82 | 82 | ||
| 83 | def __call__(self, f): | 83 | def __call__(self, f): |
| 84 | def delay(*args, **kwargs): | 84 | def delay(*args, **kwargs): |
| 85 | if self.async and self.broker_addr: | 85 | if self.async_ and self.broker_addr: |
| 86 | socket = Sender() | 86 | socket = Sender() |
| 87 | socket.connect(addr=self.broker_addr) | 87 | socket.connect(addr=self.broker_addr) |
| 88 | 88 | ||
| @@ -91,7 +91,7 @@ class Job(object): | |||
| 91 | 91 | ||
| 92 | return msgid | 92 | return msgid |
| 93 | else: | 93 | else: |
| 94 | if self.async and not self.broker_addr: | 94 | if self.async_ and not self.broker_addr: |
| 95 | logger.warning('No EMQ_BROKER_ADDR defined. Running ' | 95 | logger.warning('No EMQ_BROKER_ADDR defined. Running ' |
| 96 | 'function `{}` synchronously'.format( | 96 | 'function `{}` synchronously'.format( |
| 97 | f.__name__)) | 97 | f.__name__)) |
| @@ -101,13 +101,13 @@ class Job(object): | |||
| 101 | return f | 101 | return f |
| 102 | 102 | ||
| 103 | 103 | ||
| 104 | def job(func, broker_addr=None, queue=None, async=True, *args, | 104 | def job(func, broker_addr=None, queue=None, async_=True, *args, |
| 105 | **kwargs): | 105 | **kwargs): |
| 106 | """ | 106 | """ |
| 107 | Functional decorator helper for creating a deferred eventmq job. See | 107 | Functional decorator helper for creating a deferred eventmq job. See |
| 108 | :class:`Job` for more information. | 108 | :class:`Job` for more information. |
| 109 | """ | 109 | """ |
| 110 | decorator = Job(queue=queue, broker_addr=broker_addr, async=async) | 110 | decorator = Job(queue=queue, broker_addr=broker_addr, async_=async_) |
| 111 | 111 | ||
| 112 | if callable(func): | 112 | if callable(func): |
| 113 | return decorator(func) | 113 | return decorator(func) |