Skip to content

Commit

Permalink
[FIX] add required exception and context parameters to OdooRPC reques…
Browse files Browse the repository at this point in the history
…t events

I triggered and discovered this issues using locust's run_single_user() method used for debugging (see: https://docs.locust.io/en/stable/running-in-debugger.html)

My OdooLocustUser locustfiles triggered this exception :

[2024-06-03 16:23:59,295] dmuyshond-T590/ERROR/root: Uncaught exception in event handler:
Traceback (most recent call last):
  File "/home/dmuyshond/src/imio/locust-testcases/iavision-locust-testcases/venv/lib/python3.11/site-packages/locust/event.py", line 47, in fire
    handler(**kwargs)
TypeError: PrintListener.on_request() missing 2 required positional arguments: 'exception' and 'context'

I fixed it explicitely specifying (apparently) required and missing arguments 'context' and 'exception' in OdooLocustUser.py, inside the send() method, at the events.request.fire() methods.
  • Loading branch information
dmshd authored and nseinlet committed Jul 9, 2024
1 parent 91e6097 commit 55847f4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/OdooLocust/OdooLocustUser.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ def send(self, service_name, method, *args):
res = odoolib.json_rpc(self.url, "call", {"service": service_name, "method": method, "args": args})
except Exception as e:
total_time = int((time.time() - start_time) * 1000)
events.request.fire(request_type="OdooRPC", name=call_name, response_time=total_time, response_length=0, exception=e)
events.request.fire(request_type="OdooRPC", name=call_name, response_time=total_time, response_length=0, exception=e, context={})
raise e
else:
total_time = int((time.time() - start_time) * 1000)
events.request.fire(request_type="OdooRPC", name=call_name, response_time=total_time, response_length=sys.getsizeof(res))
events.request.fire(request_type="OdooRPC", name=call_name, response_time=total_time, response_length=sys.getsizeof(res), exception=None, context={})
return res


Expand Down

0 comments on commit 55847f4

Please sign in to comment.