![]() ![]() ![]() I don't know if Python uses pthreads under the hood, but I'm gonna assume it probably is. I started by taking a look at the pthreads (Posix Threads) glibc source code and specifications, because I was working in C++ on Linux. To get to that point, I did a bit of digging to understand better how locks worked under Linux. Also, I was convinced that you can rely on the OS to do its job and not let your thread starve. My fear was that if the locks didn't release in FIFO order, thread starvation would be likely to happen, and that would be terrible for my software.Īfter reading a bit, I dismissed my fears and realized what everyone was saying: if you want this, you're doing it wrong. I stumbled upon this post because I had a similar requirement. Running it with the QLock instead, the output should always be: ABCDEFGHIJKLMNOPQRSTUVWXYZ So it's certainly not random, but neither is it wholly predictable. On my box just now, 3 runs using threading.Lock produced this output: BACDEFGHIJKLMNOPQRSTUVWXYZ T = threading.Thread(target=work, args=(name,)) Here's a little test driver, which can be changed in the obvious way to use either this QLock or a threading.Lock: def work(name):įor name in "ABCDEFGHIJKLMNOPQRSTUVWXYZ": You can get a rough feel by studying this code, though. It's neither hard nor easy - somewhere in between - and you shouldn't use it -) I'm afraid only you can answer your "how much will I lose on processing time?" question - we have no idea how heavily you use locks, or how much lock contention your application provokes. That said, I'll show a way to implement a "FIFO lock". On most systems, that will appear to be more-or-less "random". The bog-standard, easy, and reliable way to enforce an order is to use a Queue.QueueĬPython leaves it up to the operating system to decide in which order locks are acquired. Locks provide serialization, and aren't at all intended to provide ordering. Intelligent Process Automation Consultant | Sr.I wholly agree with the comments claiming that you're probably thinking about this in an unfruitful way. Hope it helps you out and if my solution resolves your query, then please mark it as the 'Best Answer' so that the others members in the community having similar problem statement can track the answer easily in future If yes, then it will check from the queue settings how many times do I need to retry in such a case and if no then the item won't be retried at all no matter how many attempts we configure in the queue settings.Īlso, to answer our second question, if you set the Attempts field as blank and you set the ' Retry' flag as True then even in that case retry logic would not work since it will be considered that ' Attempts' value is 0 and we need to do a retry attempt at all so the item would be just marked as exception and the flow would proceed ahead. This flag in a way decides if the retry logic as a whole needs to be followed or not. ![]() So essentially with that being said, if you set the ' Attempts' more than 1 in the queue setting but let say you forget to set the Retry flag as True in your workflow while using the ' Mark Exception' action, then the queue setting for the attempt won't be considered and basically item would just be marked as exception and no new item acting as it's clone would be generated automatically in the queue. When you set the ' Retry' flag as True then only the items whenever they are marked as exception will generate a new cloned item in 'Pending' state having the 'Attempt' value incremented along it. What's the function of "Keep Locked " in Mark exception action? Consultant - Automation Developer,īlue Prism Community MVP | Blue Prism 7x Certified Professional ![]() Intelligent Process Automation Consultant | Sr. Hope it helps you and if it resolves you query please mark it as the best answer so that others having the same problem can track the answer easily NOTE: The 'Keep Locked' flag can only be used if the 'Retry' flag is True. What this does is basically it marks the item as exception, creates a clone of that item but the status is 'Locked' instead of 'Pending' so that item is immediately available for you work on. However, if in your workflow you immediately want to work on an item the moment it got marked as exception, you can go ahead and send the 'Keep Locked' flag value as True along with the 'Retry' flag as True. Whenever you set the Retry Attempts number for a work queue in your Workflow Settings under 'System' tab and you mark an item as an exception using 'Mark Exception' action along with keeping the input parameters for this action: 'Retry' flag as True, that item gets the status updated as 'Exception' and at the same time a clone of that item is created in 'Pending' state which would be picked up later on as per the FIFO algorithm. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |