Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist a data structure throughout Long run #1

Open
jrobinson-uk opened this issue Aug 7, 2022 · 3 comments
Open

Persist a data structure throughout Long run #1

jrobinson-uk opened this issue Aug 7, 2022 · 3 comments

Comments

@jrobinson-uk
Copy link

Hi I have a dictionary style object that is being interated over for my longrun process, whilst the initial run works, the schedule run fails as it can access the object any longer. Can you advise on how i might make it persist?

@inclu-cat
Copy link
Owner

Hi, unfortunately, variables in memory cannot be used between LongRun's scheduled processes.
I think you need to store that variable in a spreadsheet or something when LongRun suspends and restore it when it resumes.

@jrobinson-uk
Copy link
Author

I actually managed to get it mostly working by creating the object within the longrun init function

var params = [];
inventory = getInventory()
LongRun.instance.setMaxExecutionSeconds(30);
executeLongRun("priceMain", inventory.length, params, "priceInitializer", "priceFinalizer");
}


function priceInitializer(startIndex, params) {
  inventory = getInventory()

}

The only challenge I have now is that the longrun process iterates for the length of the object so I have to get the object once to set the run length and then set up again in the init function.

Is there a way to change the number of iterations from the init function?

@inclu-cat
Copy link
Owner

inclu-cat commented Aug 9, 2022

Is there a way to change the number of iterations from the init function?

Sorry, it doesn't have that feature at this time.
As a workaround, you might be able to set the number of iterations large at first and skip immediately at "priceMain" function if the index is greater than the number you actually need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants