For Python 2, patching existing locks replaces RLock._RLock__owner with current thread ID no matter the old lock is locked or not and thus an unlocked RLock would have a non None owner (e.g. <_RLock owner=140106584489808 count=0>). Then if we acquire the RLock in the same thread, the method RLock.acquire would not invoke the _RLock__block.acquire() since it treats this is a recursive acquire by checking current thread ID. And then the following RLock.release would invoke the _RLock__block.release method resulting in the counter of Semaphore being improved to 2. There should be only two states being expected for RLock: 1. owner != None and count > 0 2. owner == None and count == 0 This patch fixs it by only setting locked RLocks' owner during patching.
The tests are intended to be run using Nose. http://somethingaboutorange.com/mrl/projects/nose/ To run tests, simply install nose, and then, in the eventlet tree, do: $ nosetests That's it! Its output is the same as unittest's output. It tends to emit a lot of tracebacks from various poorly-behaving tests, but they still (generally) pass.