cancel
Showing results for 
Search instead for 
Did you mean: 

Environmental Locks - Release

ChiragSurati
Level 4
The Main Process calls a subprocess that checks-out a credential from a pool of credentials to be used in the main process. However, it is releasing the credential back to the available pool and another bot is trying to use the same credentials and causing errors. Why would a subprocess release a lock without the Release Lock action? Thank you Chris   
4 REPLIES 4

AndreyKudinov
Level 10
I might be wrong here (depends on your actual process), but when subprocess ends, it autoreleases all locks it holds (which is not what you want sometimes). Basically lock holds as long as object that acquired it is alive. I can think of two options:  1) Using some external way of locking (create/delete files or use external database)  2) Create a queue item with specific key for each lock, then delete that item from queue when you need to release lock. Just locking queue item won't do either, because it will mark queue item with exception when subprocess exits if you don't release it.   p.s. I personally used second approach myself when I need to set a persistent lock. I also abused work queues to create a lock with a counter, where multiple processes can ""acquire lock"" and you can tell how many/if any still hold it. It could be kinda useful if blueprism provides both persistent lock and RWLock style thing.

ChiragSurati
Level 4
aikudino I have one subprocess acquiring the lock and the second one releasing the lock. You're telling me this is the incorrect approach because as soon as the first subprocess completes it automatically releases the lock. You mentioned using another approach to manage this is to use an external file. How would I go about doing that?

AndreyKudinov
Level 10
Check lock comment after first process exits, it should say ""Automatically released when session finished"" - that means you got the problem I described, which is locks are not persistent. Create some queue, call it Locks for example and use that to store your locking state. For example, you can add item ""myprocessnamelock"" and check it's existence, delete it to ""release"" lock or use Tags, Status, whatever - up to you. Just don't rely on get item, that would go into exception state after process ends as well (but item stays in queue).

AndreyKudinov
Level 10
You can check BP VBOs: Utility - Locking or Utility - Foreground Locker - both use queues for locking instead of environmental locks.