Process counter across multiple process instances

I have a process which will run multiple instances at the same time. I also want an asset which specifies how many queue items to process.

If a single instance is running then this would be simple;. Have a counter and check that it is less than the asset.

How would I implement it across multiple instances to limit the total processing count

eg if I set it to 30 and VDI 1 did 10, VDI 2 did 12 then VDI 3 would do 8 to make up 30.

Any suggestions would be helpful

There are a few solutions which vary in technical scope.

  • One would be to simply update a shared file with a value or even update the file name within a folder to the number of items worked and use that.

  • Another would be to update a database for each work completed and use that as a reference via SQL

  • You could create an integer asset using APIs that gets updated each time a piece of work is completed and then the next user would retrieve it to check.

  • I’d like to avoid using a shared file (although I have used this in previous automation)
  • Unfortunately I don’t have access to an SQL database
  • How would this work in terms of contention between processes, I would need the automation to be able to handle if 2 instances of it tried to update the variable at the same time which may be difficult to do.

I thought about this for a good minute, and I’m just thinking of this idea.
It seems like the challenge is how do you manage 2 instances that try to process at the same time…

So you need to be able to see that there is not another instance trying to process at the same time and prioritize them. What if you store a string that lists all the instances or just a single instance that is trying to process (like in an Asset), wait a few seconds, check the asset to make sure it has priority still, check counter to make sure it’s <= 30, then process. - meanwhile, the second instance is waiting til it has priority, and if it gets priority but is > 30, it won’t process.

Something like that.

1 Like

I was thinking of something similar to @ClaytonM.

You could use a boolean asset to store if a robot is trying to increment the asset counter.

  1. Do While Loop
    • GetAsset - IncrementCounterLock
      • IF True - Delay (X Seconds)
      • ELSE - Set Asset = IncrementCounterLock = True
  2. GetAsset - IncrementWorkCounter
    • Assign - IncrementWorkCounter = IncrementWorkCounter + 1
  3. SetAsset - IncrementWorkCounter
  4. SetAsset - IncrementCounterLock = False

This way it will only increment the counter one at a time without contention.