I'm writing a custom sub-class of Queue.Queue and run into a situation where I need to acquire a queue-level lock when my custom put()
is being called. I'd like to reuse the existing lock Queue has (Queue.mutex
), but can't because its not an RLock
.
In the source (python 2.6), it says:
# Override these methods [_put, _get, etc] to implement other queue organizations
# (e.g. stack or priority queue).
# These will only be called with appropriate locks held
But the online documentation doesn't mention overriding them. The other Queue implementations in that module override these. So, I'm kinda inclined to believe that the _put
method is package-private and isn't really intended for use outside the Queue module.
Does anyone know how kosher it would be to use Queue._put
and friends in my own subclass?