• Kirill Smelkov's avatar
    sync.WorkGroup: Fix deadlock thinko in tests · b8b042c5
    Kirill Smelkov authored
    sync.WorkGroup test was doing ctx.done() wait from under test mutex,
    something like
    
        def _(ctx, i):
            with mu:
                ...
                if i == 0:
                    raise RuntimeError()    # to cause ctx cancel
                ctx.done().recv()           # i=1 -> wait till ctx is canceled
    
    but it can be a deadlock if T(i=1) runs first and enters
    ctx.done().recv() before T(i=0) is run - then T(i=0) will block forever
    waiting to lock mu.
    
    This failure was not seen so far, probably because the time to go a new
    thread/goroutine is relatively high. However one of upcoming patches,
    where go is made faster, revealed this problem and, without the fix,
    sync.WorkGroup test was regularly deadlocking.
    
    The problem was there from sync.WorkGroup beginning - from
    9ee7ba91 (sync += WorkGroup).
    
    Fix the deadlock by waiting for ctx.done() outside of mu.
    b8b042c5
Name
Last commit
Last update
golang Loading commit data...
gpython Loading commit data...
.gitignore Loading commit data...
CHANGELOG.rst Loading commit data...
COPYING Loading commit data...
MANIFEST.in Loading commit data...
README.rst Loading commit data...
setup.py Loading commit data...
tox.ini Loading commit data...