Home > Mobile >  Locust-plugins; Uncaught exception in event handler: TypeError: fire_deprecated_request_handlers() m
Locust-plugins; Uncaught exception in event handler: TypeError: fire_deprecated_request_handlers() m

Time:01-04

I've built a working locust-plugins web-driver script and was attempting to add some transactional timers and when I run the script I'm getting an error:

[2022-01-03 10:34:55,525] LHTU05CD943125T/ERROR/root: Uncaught exception in event handler: Traceback (most recent call last): File "C:\Program Files (x86)\Python38-32\lib\site-packages\locust\event.py", line 40, in fire handler(**kwargs) TypeError: fire_deprecated_request_handlers() missing 1 required positional argument: 'context'

The script continues to run but at every event call I see the above error. I'm using locust version 2.5.1 and locust-plugins version 2.1.1.

@task
def open_digipass_homepage(self):
    self.clear()

    # CALL THIS ONCE
    start_time = time.monotonic()

    self.client.get("https://myurl-stage.com/")

    self.environment.events.request.fire(
        request_type="transaction",
        name="T000_SitePage",
        response_time=(time.monotonic() - start_time) * 1000,
        response_length=0,
        exception=None
    )

CodePudding user response:

Your self.environment.events.request.fire call is missing and argument it's expecting called context. This may or may not be a bug (not sure something like this should be required, if it is), but you should be able to work around it. Here's the documentation on the event signature:

http://docs.locust.io/en/stable/api.html#locust.event.Events.request

Which links to this page on what the Context is supposed to be:

http://docs.locust.io/en/stable/extending-locust.html#request-context

Looks like it's a dictionary with whatever stuff you want to get passed around. Based on some code in the tests I'd assume adding even just context={} to your call should work. Something like this:

self.environment.events.request.fire(
    request_type="transaction",
    name="T000_SitePage",
    response_time=(time.monotonic() - start_time) * 1000,
    response_length=0,
    exception=None,
    context={}
)

CodePudding user response:

Thank you very much, that was the issue and it works fine now.

  •  Tags:  
  • Related