Can Scripts Operate in Background?

In a separate thread - Script: sync Zotero to DTPro - I have been trying to figure out why a specific script has been behaving inconsistently in various ways, including importing data to a different database than defined in the script (i.e. randomly to a database I had been using recently for other reasons).

This has gotten me thinking more generally - is it OK to run a script in the background while doing other tasks? Or does that create conflicts in the file system and otherwise?

Are there rules of how to write a script to not conflict with DT3 tasks which may be operating in a different active DT3 window or otherwise concurrently running on DT3?

Or if I want a script to run in the background do I need to set that up on a different user account on my computer and then sync the database(s) between the two accounts?

This would all depend on it you’re messing with files being affected by the script.

Or if I want a script to run in the background do I need to set that up on a different user account on my computer and then sync the database(s) between the two accounts?

Depending on what you’re doing, this could create sync conflicts. Not guaranteed, but possible.

Perhaps you need to rethink how many things you’re trying to automate. You’re not going to be able to set up a perpetual motion engine with multiple processes running unless they are very strictly controlled
(I did it years ago on a server that ran a production process all day, rebooted itself at 3am, then continued with it’s chores unattended - every day for several years. But again, that was a very strict process without anyone messing with it.)

Agreed I may need to rethink that

That said, the processes being automated by the different scripts are different files in different databases. Oddly though, when I use DT3 in another window while the script is operating, the script shifts to start saving the files in the inbox of the new database I am using.

So is it posible for one script to work in one database and another script (or an active user) to work in another database at the same time?

@cgrunenberg would have to respond to that. I know running scripts from the scripts menu have to wait their turn, i.e., You can’t launch multiple scripts at the same time there.

Yes I noticed that. In fact, I tried a workaround because of that - perhaps not wisely. I was editing the script and knew that I might want to terminate it early rather than wait for it to process the entire input set. But there were some recently uploaded files being OCR’d in the background and other users were accessing the web server which is hosted by the same account. So I knew I would not want to shut down DT3 entirely. Therefore I ran the script directly from Script Editor so that I could terminate that process without affecting the other tasks operating on DT3.

I think a smarter route in the future would be for me to create a separate user account for “Experimental” or “Development” purposes so that I don’t have to worry about terminating that DT3 instance affecting the other tasks.

I blame you fully for all of this - there are quite a number of regular office processes which rely on DT3 throughout the day given the new features added over the last year :slight_smile:

Blame @cgrunenberg! He’s the genius behind all this madness :slight_smile:

I’m just the Igor (pronouned “Eye-gor”) to the doctor(s). :stuck_out_tongue:

1 Like

Multiple scripts aren’t executed concurrently.

How does the script look like? E.g. scripts using the selection, the currently opened windows/tabs or the current database/group etc. might of course not always work the same way.

Thanks - I will try it on a separate user account instead.