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.

Samples with response_time None crashes stats.py

See original GitHub issue

Certain 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:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
heymancommented, Oct 18, 2019

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.

0reactions
cyberwcommented, Oct 21, 2019

I’ve fixed the issues with calculating averages and median.

Read more comments on GitHub >

github_iconTop 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 >

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