"Reentrant" may not be the right term, but I think it is close.
If I share a script with another user and we both execute it at the same time do we over-write each others variables?, or do the two executions happen in entirely distinct memory spaces?
Where can I read about this?
If reentrant is the wrong term, what is the correct one?
Update 14/10/03 o9:45 EDT: I don't think this warrants asking a new question.
I understand from Serge and Henrique that separate executions are "thread-safe" and that operations on shared resources need protection, presumably with Lock Service.
I am trying to decide how to rationalize my current ad hoc "strategy". I have a Web App that uses a spreadsheet for keeping track of a lot of settings, including querying another large spreadsheet for short-listed data. I shared copies with another user, then another. Now I have a mess of spreadsheets and script copies to keep track of. (It grew that way -- don't ask). I don't want to lose the "local cache" spreadsheets but I do want to avoid unnecessarily sharing multiple copies of a thread-safe script.
I'm considering a centralized lookup table that pairs a local cache spreadsheet with a given user, but it is really starting to look like I should rewrite the whole thing with BigQuery or some such, more serious storage. That looks like more effort than its worth though.
Any suggestion would be appreciated.
Update 14/10/03 12:15 EDT:
Originally the WebApp was contained in the spreadsheet, but I moved it out, so they are shared together. To add to the craziness. I now have a script that uses DriveApp to create directories, sharing with a user, copying in the spreadsheet and script and a few other things. In fact for security sake, in addition to the WebAppScript, I have WebAppScriptProxy that publishes the public functions of WebAppScript. That one is what the user interacts with.
It's in entirely distinct memory spaces.
I don't think "reentrant" is the most accurate term here, since there's no interruption of one's code to run another's. They all happen concurrently and safely. I'm not really sure what the correct term is. I guess you could say that the whole environment is "thread-safe", as they execute in different threads/processes and no variables are shared.
You only have to take care of shared resources, like a common spreadsheet or document property, etc.
--edit
It's difficult to understand your setup, but I'll suggest an approach anyway. First of all, I recommend that you have one only script and share only its deployed URL with your users (and not the script itself). About going Spreadsheet vs BigQuery, it's really impossible to advise against BigQuery. If you have the knowledge and are willing to work with it, then go for it. But I think you can work something out with Google Sheets, which due to its inherit concurrency nature is a pretty good simple database for scripts.
Bottom line, share with your users only what you must and keep everything else hidden. It's simpler for them and for you that way. For example, if they do not need to edit your "local cache" spreadsheet manually, then do share it with them. Again, if everything they need is the link to access your web-app, then don't make it more complex.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With