Skip to content
Snippets Groups Projects
Commit 5bb28ddd authored by Fynn Becker's avatar Fynn Becker :crab:
Browse files

Change name parameter to avoid naming clashes

parent 5c6a90a8
No related branches found
No related tags found
No related merge requests found
...@@ -31,10 +31,10 @@ class RPCMessageQueueError(RPCError): ...@@ -31,10 +31,10 @@ class RPCMessageQueueError(RPCError):
all_tasks = set() # each registered task will show up here all_tasks = set() # each registered task will show up here
def run(name, **kwargs): def run(_task_name, **kwargs):
""" """
Runs a task remotely. Runs a task remotely.
:param name: name of the task to run :param _task_name: name of the task to run
:param kwargs: kwargs for the task :param kwargs: kwargs for the task
:return: None :return: None
""" """
...@@ -44,7 +44,7 @@ def run(name, **kwargs): ...@@ -44,7 +44,7 @@ def run(name, **kwargs):
channel.confirm_delivery() channel.confirm_delivery()
channel.basic_publish( channel.basic_publish(
exchange=settings.CLIENT_EXCHANGE_NAME, exchange=settings.CLIENT_EXCHANGE_NAME,
routing_key=name, routing_key=_task_name,
body=utils.serialize(kwargs), body=utils.serialize(kwargs),
properties=pika.BasicProperties() properties=pika.BasicProperties()
) )
...@@ -52,11 +52,11 @@ def run(name, **kwargs): ...@@ -52,11 +52,11 @@ def run(name, **kwargs):
raise RPCMessageQueueError(e) raise RPCMessageQueueError(e)
def rpc(name, **kwargs): def rpc(_task_name, **kwargs):
""" """
Runs a task remotely and returns its result. Runs a task remotely and returns its result.
Raises RPCError if there were problems. Raises RPCError if there were problems.
:param name: name of the task to run :param _task_name: name of the task to run
:param kwargs: kwargs for the task :param kwargs: kwargs for the task
:return: whatever the task returned :return: whatever the task returned
""" """
...@@ -80,7 +80,7 @@ def rpc(name, **kwargs): ...@@ -80,7 +80,7 @@ def rpc(name, **kwargs):
""" run by pika simple timer """ """ run by pika simple timer """
nonlocal exception nonlocal exception
channel.stop_consuming() channel.stop_consuming()
exception = RPCTimedOut("RPC timed out. Task: {t}. Channel: {c}".format(t=name, c=channel)) exception = RPCTimedOut("RPC timed out. Task: {t}. Channel: {c}".format(t=_task_name, c=channel))
try: try:
with utils.get_connection() as conn: with utils.get_connection() as conn:
...@@ -91,7 +91,7 @@ def rpc(name, **kwargs): ...@@ -91,7 +91,7 @@ def rpc(name, **kwargs):
# send a request # send a request
channel.basic_publish( channel.basic_publish(
exchange=settings.CLIENT_EXCHANGE_NAME, exchange=settings.CLIENT_EXCHANGE_NAME,
routing_key=name, routing_key=_task_name,
body=utils.serialize(kwargs), body=utils.serialize(kwargs),
properties=pika.BasicProperties( properties=pika.BasicProperties(
reply_to="amq.rabbitmq.reply-to", reply_to="amq.rabbitmq.reply-to",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment