Changelog: I added a mutex lock around nfail = nfail + 1.
nfail = nfail + 1
Changelog: I wrapped the coroutines in tasks for Python ≥ 3.11 compatibility