pglass/how-do-i-locust

Probably wrong parameter in async_failure call after the while loop is finished

KirillY opened this issue · 1 comments

Maybe you wanted to raise failure for the polling request, which is declared as:
r = self.client.get('/things/' + id)
So the result may look so:

while time.monotonic() < end_time:
...
    async_failure('POST /things/ID - async', start_time, r, 'Failed - timed out after %s seconds' % timeout)

Where post_resp -> r

No, the code is what I intended.

Look closely at the async_failure method. It uses the response object to set the “type” column in Locust’s “statistics” table, in this case for the POST /things/ID - async row. Therefore, I pass the post_resp into the async_failure function, so that it records type=POST for that entry in the statistics table. (If we were to pass the polling request r, it would set type=GET instead).

This is what makes sense to me, but it is up to personal preference. I think you could set that “type” column to whatever value you like in the statistics table.

Remember that every individual http response is recorded by default into the statistics table. The purpose of that “Asynchronous polling” section is to show how to record an additional custom operation that is not just a plain http request.