Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to abort the infinite loop trigger in script console

Sheeraz Ali June 12, 2018

Hi, 

I ran a groovy script in script console that was updating jira issues around 1500 and it gave me timeout error on the page of script console but i observed that the script was running in the background doing its work!. My Questions are,

  1. Is there a way to increase that page timeout until the script has been completed.
  2. I was wondering if in the worst case an infinite loop has been triggered or even a script updating 100 thousand issues once triggered can be interrupted or not? If yes then how can we do that?

BR

Sheeraz

1 answer

0 votes
Thanos Batagiannis [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 17, 2018

Hi Sheeraz,

Regarding your first question I am not sure that you can dynamically set the page time out within ScriptRunner. 

For your second question a solution would be to have some type of timer. In code this should be something like

def startTime = System.currentTimeMillis()
def endTime = 5000 // in milliseconds, so 5000 ms = 5 sec

//infinite loop
while (true) {

log.debug "I am running ..."
// od something

if (System.currentTimeMillis() - startTime > endTime) {
log.debug "TIme passed I will end it now"
return
}
}

But before you go with a solution like this, you have to think a bit more about the consequences, for example if there is an infinite loop somewhere then is better to find this out and fix it, the timer will just cover the issue. 

Also lets say in your scenario that your script updates thousands of issues and then after some time it stops, because of the timer. Then how do you know which issues got updated and which not (maybe with some logging), but my point is that the actions of a scriptshould be clear. Under which conditions should run, what is the expected result and when it ends.

Hopefully you see my point. 

Kind regards, Thanos 

Sheeraz Ali July 17, 2018

Hi Thanos,


Thanks for your reply and yes i can see your point here that script should be clear and well handled to cover up all the scenarios and should not trigger the infinite loop in the first place. My concerns were about the environment in which we are running a script, here in our case is script console that there should be some kind of interrupt button/signal or something to halt the execution of the script to avoid triggering any cases where the only available option seems to be the jira service restart even disabling the plugin doesn't seem to work.

BR
Sheeraz

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events