Stop Polling based on condition


I have a query around Gatling Polling. I have checked the documentation here: and went through similar questions in the forum. I couldn’t find an answer hence posting it here. If an answer to this skipped my search my apologies and I will be happy if you can point to it.

Gatling version: 2.31.

To poll an endpoint until a “status” is set in session.

To solve this problem I would like to use Polling and want to conditionally stop polling once the session has “status” I have cloned the gatling-sbt-plugin-demo project and modified it to poll every 1000 milli seconds. And checking the session for “status” attribute and when found stop polling. The code looks like this.


val scn = scenario(“Scenario Name”)






.every(1000 milli)



.check(status.saveAs(“status”)))).exec(doIf(session => session.contains(“status”)) {



setUp(scn.inject(constantUsersPerSec(1) during(1 minute)).protocols(httpConf))


When I run this I don’t see the polling stopping when the status is set in the session.

My questions are:

  1. Am I using polling.stop correctly?
  2. Can I stop polling based on a condition and is my usage correct?
  3. If it is correct, am I trying to stop in the wrong place i.e only after the polling is completed?

If you can point me out or guide me what is incorrect here, it will be very helpful.

p.s we tried using AsLongAs with a check in the session and we got that working. But because I couldn’t see a break point or timeout to be used in AsLongAs we are considering using polling.

Thanks for your time.