question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception in task method is handled but not reported as a failure

See original GitHub issue

Description of issue

If an unhandled exception occurs in a task method it is handled by the framework and tasks continue to be executed by the Locust but not reported as a failure. If you are only looking at the final success / failure rate - perhaps programmatically - it is easier to miss the exception. From the UI you can see exceptions more easily, and download them as a CSV, but when running in --no-web mode they are not logged.

Expected behavior

My proposal is

  • an exception should be treated as a failure and logged as such.
  • exceptions should be exported as a CSV when using --no-web

Actual behavior

Exceptions are not treated as a failure - in fact tasks appear to have succeeded, and they are not logged to in the CSV outputs on --no-web mode.

Environment settings

N/A

Steps to reproduce (for bug reports)

Write any task where the code after making the web request fails - perhaps asserting something on the output, or manipulating data it thought would be returned but wasn’t.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
WayneKeenancommented, Aug 15, 2019

Also, if I have a body of existing code used for testing support being able to just rely on standard python exceptions failing the test is a big plus.

Other than this little niggle Locust is perfect for our needs, I found it yesterday (JMeter casualty) and up and running in no time. Amazing work, a shining example of following the path of least surprise.

Thank you! Wayne

0reactions
heymancommented, Oct 27, 2019

This then begs the question - could we get aggregated stats for task sequences and other nested task sets?

You should be able to implement it within your own test scripts by overriding the TaskSet.execute_task method, and firing locust.events.request_success events. However I’m -1 on including it in Locust itself.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why exceptions in async methods are “dangerous” in C#
No exception was thrown because the MyAsyncMethod routine is not awaited and the exception is literally lost with the Task. In that case,...
Read more >
Exception handling in async methods C# - Stack Overflow
In the async case, the precondition exceptions are used to fault the task, not raised directly. This is how I do precondition exceptions....
Read more >
Exception handling (Task Parallel Library) - Microsoft Learn
Explore exception handling using the Task Parallel Library (TPL) in .NET. See nested aggregate exceptions, inner exceptions, unobserved task ...
Read more >
Exception Handling in C# Asynchronous Programming
The reason is because when an asynchronous function fails to execute a Task, it throws a Task Cancelled exception. We need to implement...
Read more >
How to Handle Asyncio Task Exceptions - Super Fast Python
A coroutine wrapped by a task may raise an exception that is not handled. This will fail the task, in effect. We can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found