The asycion.wait() function doesn't promise to stop the world after exactly one task completes. It also doesn't promise to return immediately. So if multiple locks *can* be acquired there are many paths through the code that will let them be acquired, and wait() will report at least one of them (unless the timeout happens) -- that's all you can trust.
What are you trying to accomplish? Most things using asyncio don't require locks. On Wed, Mar 19, 2014 at 11:46 AM, Imran Geriskovan < [email protected]> wrote: > Code below has been written with the intension of acquiring ONLY one lock. > There are two issues: > > 1- Sometimes it returns more than one lock in done. > 2- Sometimes, even if wait exits with zero or one lock, it seems > there are other locks are acquired too. Though, I couldn't isolate > the exact case for this. > > It sounds like some background shield() is at works. > > I kindly request your comments. > > > locks = [some asyncio.Locks...] > sel = [Pack(l.acquire(), l) for l in locks] > done, pend = asyncio.wait(sel, timeout=10, return_when=FIRST_COMPLETED) > ... > @coroutine > def Pack(co, obj): > yield from co > return obj > > > Regards, > Imran > -- --Guido van Rossum (python.org/~guido)
