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
98c0d45fd271
Commit
fd8a1cdf
authored
Jan 16, 2017
by
Philippe Pepiot
Browse files
[entities] use try/except to get or create CeleryTask
IMHO this looks better than "if rset". Also log created entity eid.
parent
511c159acb12
Changes
1
Hide whitespace changes
Inline
Side-by-side
entities.py
View file @
98c0d45f
...
...
@@ -273,15 +273,15 @@ class CeleryTaskAdapter(ICeleryTask):
for
asr
in
tree
(
result
):
task_id
=
six
.
text_type
(
asr
.
id
)
rset
=
self
.
_cw
.
find
(
'CeleryTask'
,
task_id
=
task_id
)
if
rset
:
cwtask
=
rset
.
one
()
else
:
self
.
info
(
"create a CeleryTask for %s"
%
task_id
)
try
:
cwtask
=
self
.
_cw
.
find
(
'CeleryTask'
,
task_id
=
task_id
).
one
()
except
NoResultError
:
cwtask
=
self
.
_cw
.
create_entity
(
'CeleryTask'
,
task_name
=
UNKNOWN_TASK_NAME
,
task_id
=
six
.
text_type
(
task_id
))
self
.
info
(
"Create <CeleryTask %s (task_id %s)>"
,
cwtask
.
eid
,
task_id
)
if
not
cwtask
.
parent_task
and
self
.
entity
is
not
cwtask
:
self
.
info
(
'Set %s parent_task to %s (%s)'
,
cwtask
.
task_id
,
self
.
entity
,
self
.
entity
.
task_id
)
...
...
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