Samples with response_time None crashes stats.py
See original GitHub issueCertain async protocols/clients (like websockets, MQ etc) dont really have a response time. They should be able to report a None response time. Using zero is not good enough, because a test may contain a mix of synchronous requests (like HTTP) and async, and we dont want to “taint” the average response time with zeroes.
from locust import HttpLocust, task, TaskSet
from locust.events import request_success
class UserBehavior(TaskSet):
@task
def my_task(self):
request_success.fire(request_type="foo", name="bar", response_time=None, response_length=0)
class MyHttpLocust(HttpLocust):
task_set = UserBehavior
Result:
[2019-09-22 09:57:13,877] lafp-mac-JG5J.int.svenskaspel.se/ERROR/stderr: Traceback (most recent call last):
File "/Users/lafp/git/locust/locust/core.py", line 361, in run
self.execute_next_task()
File "/Users/lafp/git/locust/locust/core.py", line 387, in execute_next_task
self.execute_task(task["callable"], *task["args"], **task["kwargs"])
File "/Users/lafp/git/locust/locust/core.py", line 399, in execute_task
task(self, *args, **kwargs)
File "/Users/lafp/git/locust-plugins/examples/foo.py", line 10, in my_task
request_success.fire(request_type="foo", name="bar", response_time=None, response_length=0)
File "/Users/lafp/git/locust/locust/events.py", line 34, in fire
handler(**kwargs)
File "/Users/lafp/git/locust/locust/stats.py", line 559, in on_request_success
global_stats.log_request(request_type, name, response_time, response_length)
File "/Users/lafp/git/locust/locust/stats.py", line 93, in log_request
self.total.log(response_time, content_length)
File "/Users/lafp/git/locust/locust/stats.py", line 239, in log
self._log_response_time(response_time)
File "/Users/lafp/git/locust/locust/stats.py", line 250, in _log_response_time
self.total_response_time += response_time
TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType'
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Response Time Limits: Article by Jakob Nielsen
How users react to delays in a user interface, whether website or application. The 3 main response time limits are determined by human...
Read more >Performance Testing Tutorial – Types (Example) - Guru99
1. Know your physical test environment, production environment and what testing tools are available. 2. This includes goals and constraints for throughput, response...
Read more >A Complete Non-Functional Testing Guide for Beginners
A Complete Guide to Non-Functional Testing: Its Purpose, Types, Tool, Test Cases with Examples. What is Non-Functional Testing?
Read more >Operating Systems: CPU Scheduling
If scheduling takes place only under conditions 1 and 4, the system is said to be non-preemptive, or cooperative. Under these conditions, once...
Read more >Traffic Safety Facts Annual Report Tables
In this annual report, Traffic Safety Facts: A Compilation of Motor Vehicle Crash Data, the National Highway Traffic Safety Administration ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I agree that it makes sense to be able to report requests without response times so that they wouldn’t taint the stats for ordinary requests.
The #1088 PR should have tests. I’m a little bit concerned that the changes could have unintended effects since the code up until now have always assumed that each request has a response time. That might be an unfounded concern though, but in any case, I think these changes should come with multiple tests where non-response-time requests are made both by themselves, as well as together with “normal” requests that have a response time.
I’ve fixed the issues with calculating averages and median.