Commit df37a4d1 authored by Nicola Spanti's avatar Nicola Spanti
Browse files

[py] Manage case `result.info` is an exception

In a client project, we add the case of `result.info` being
`UException` (from `cubicweb_nemo.utils`). It resulted in a
problem, because `result.info` is `True` as boolean, but it has
no key, so it crashed. This patch does not resolve the real
problem of having a clean `info` member or knowing why it could
normally have a different type, but at least it eliminates a
problem for the final users.
parent 256d437ec4d9
......@@ -13,7 +13,7 @@
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
"""cubicweb-celerytask entity's classes"""
import six
......@@ -204,15 +204,17 @@ class ICeleryTask(EntityAdapter):
if celery.current_app.conf.task_always_eager:
return 1.
result = self.result
try:
if result.info and 'progress' in result.info:
return result.info['progress']
elif self.entity.reverse_parent_task:
except TypeError:
pass
if self.entity.reverse_parent_task:
children = self.entity.reverse_parent_task
return sum(child.cw_adapt_to('ICeleryTask').progress
for child in children) / len(children)
elif result.state == STATES.SUCCESS:
if result.state == STATES.SUCCESS:
return 1.
else:
return 0.
@property
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment