Skip to content
Snippets Groups Projects
Commit 8781070c authored by Art's avatar Art :lizard:
Browse files

Remove WORKER_REPLYTO_EXCHANGE, fix docstring for the @task decorator.

parent 3eb81da1
Branches
No related tags found
No related merge requests found
......@@ -89,8 +89,8 @@ def rpc(name, **kwargs):
def task(name):
"""
Use this to decorate your tasks.
:param queue: queue name, defaults to the task name
:return: callable object, that can be used by various pika consumption methods
:param name: name of the task and its queue
:return: callable object, ready to be consumed by pika's functions like Channel.basic_consume
"""
assert isinstance(name, str)
......@@ -114,7 +114,10 @@ def task(name):
try:
logger.debug("Sending the result of {name} to {properties.reply_to}.".format(**locals()))
reply = {"error": func_error} if func_error else {"result": func_result}
channel.basic_publish(exchange=settings.WORKER_REPLYTO_EXCHANGE, routing_key=properties.reply_to, body=utils.serialize(reply))
channel.basic_publish(
exchange="", # empty string as specified in RabbitMQ documentation, section direct reply-to
routing_key=properties.reply_to,
body=utils.serialize(reply))
except Exception as e:
logger.error("Could not reply to the {properties.reply_to}. {e.__class__.__name__}: {e}".format(**locals()))
else:
......
......@@ -21,7 +21,6 @@ WORKER_TASK_PROCESSES = 10 # this many processes will be executing tasks
# stuff you might want to change sometimes:
RPC_TIMEOUT = timedelta(seconds=10) # affects client behaviour and message TTL
WORKER_GRACEFUL_STOP_TIMEOUT = timedelta(seconds=60)
WORKER_REPLYTO_EXCHANGE = ""
# stuff you probably don't want to touch:
BLOCKED_CONNECTION_TIMEOUT = timedelta(seconds=20) # weird stuff to avoid deadlocks, see pika documentation
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment