Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubes
celerytask
Commits
31615252fcfa
Commit
445abf4a
authored
Nov 17, 2017
by
Philippe Pepiot
Browse files
Force passing a cnx to run_all_tasks()
This has been deprecated for a while, make this mandatory.
parent
1ef783692e79
Changes
1
Hide whitespace changes
Inline
Side-by-side
entities.py
View file @
31615252
...
...
@@ -17,7 +17,6 @@
"""cubicweb-celerytask entity's classes"""
import
six
import
warnings
import
celery
from
celery.result
import
AsyncResult
,
from_serializable
...
...
@@ -43,12 +42,8 @@ def get_tasks():
return
_TEST_TASKS
.
copy
()
def
run_all_tasks
(
cnx
=
None
):
def
run_all_tasks
(
cnx
):
"""Run all pending tasks (for use in cubicweb test mode)"""
if
cnx
is
None
:
warnings
.
warn
(
'cnx argument should be specified to enable task '
'workflow synchronisation'
,
DeprecationWarning
,
stacklevel
=
2
)
results
=
{}
# run all tasks and gather results.
# Tasks can create other tasks, so run them until there is no one left.
...
...
@@ -56,7 +51,7 @@ def run_all_tasks(cnx=None):
task_eid
=
list
(
_TEST_TASKS
)[
0
]
results
[
task_eid
]
=
_TEST_TASKS
.
pop
(
task_eid
).
delay
()
if
cnx
is
not
None
and
celery
.
current_app
.
conf
.
CELERY_ALWAYS_EAGER
:
if
celery
.
current_app
.
conf
.
CELERY_ALWAYS_EAGER
:
for
task_eid
,
result
in
results
.
items
():
wf
=
cnx
.
entity_from_eid
(
task_eid
).
cw_adapt_to
(
'IWorkflowable'
)
transition
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment