Asyncio RLock - reentrant locks for async Python

For asyncio-rlock I see very few usages on the github. Maybe the feature request is not very popular?

Might be. Or maybe people just wrote their own implementation. Or they swallowed the pill of having to refactor their code to work with simple locks.

Looking at Code search results · GitHub you can see 4 libs or so that rolled their own solution. Possibly more that I didn’t find because they could’ve named their class whatever.

Given that it’s not a lot or complex code and there is some (hard to measure) demand, I think it would be a cheap and worthy addition to asyncio.

To elaborate on my use-case: I had a decently sized, sync code-base that I wanted to port to async Python. The code used threading.RLock. So I had the option to rethink and refactor the whole thing to only use simple locks or write my own RLock. As said it felt very awkward to have async ship without batteries.

1 Like