Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pikatasks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
django
pikatasks
Commits
5bb28ddd
Commit
5bb28ddd
authored
7 years ago
by
Fynn Becker
Browse files
Options
Downloads
Patches
Plain Diff
Change name parameter to avoid naming clashes
parent
5c6a90a8
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pikatasks/__init__.py
+7
-7
7 additions, 7 deletions
pikatasks/__init__.py
with
7 additions
and
7 deletions
pikatasks/__init__.py
+
7
−
7
View file @
5bb28ddd
...
@@ -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
"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment