Break loop doesn't work

Hello, wonderful people!

I spent a few hours trying to google any solution of how to break the loop on condition but nothing works. Please help me

I have the following blocks in my scenario but attribute “continue” is always “true”. I tried lots of things including session reset() and creating new attribute with the name “continue” - but still can’t override it

.exec(session => session.set("continue", true))
.asLongAs(session => session("continue").as[Boolean]) {
  pause(15 seconds)
      http("check job status")
        .get("/v1/commercial-schemes/" + commercialScheme + "/accounts/inventory/imports/${jobid}")
        .header("Authorization", "Bearer " + "${token}")
    .exec { session =>
      logger.debug("Current job state: " + session("state").as[String] + " and job result: " + session("result").as[String])
      if (session("state").as[Int] == 7) {"Bulk cards import job finished with status: " + session("result").as[String] + " card prefix is: " + session("cardprefix").as[String])
        session.set("continue", false)

Please give me some clues on how I can implement a loop and exit it as soon as service returns job status "7 - COMPLETED"

P.S. I use version 3.3.0

Well, quite often, reading the official documentation works better than random googling…

session.set(“x”, “y”) returns new session instance which must be returned if you want to preserve the change between chained exec blocks :slight_smile:

if (session(“state”).as[Int] == 7) {"Bulk cards import job finished with status: " + session(“result”).as[String] + " card prefix is: " + session(“cardprefix”).as[String])
session.set(“continue”, false)
} else {