"Named" locks #723
Unanswered
davidbrochart
asked this question in
Q&A
Replies: 1 comment 1 reply
-
|
I think this is indeed beyond AnyIO's scope, as it doesn't seem generic enough to warrant inclusion in this project. I also take issue with the fact that if the lock is contested by multiple tasks, it wakes up every single one of them when a lock is exited even when only one task just needs to be woken up. That |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It might be out of AnyIO's scope, but I often need a lock that is tied to an ID (or more generally a hashable object). For instance, resources on a file system could be represented by their path, and if I want to prevent concurrent access to the same resource, I'd like to write something like:
Maybe I'm missing something, but nothing in the synchronization primitives seems to offer that functionality easily. Here is what I currently use:
It actually doesn't use any
Lock. Do you see something wrong with that approach? Or do you think it could be better implemented?Beta Was this translation helpful? Give feedback.
All reactions