@@ -0,0 +1,1267 @@
+import asyncio%0Aimport logging%0Aimport pytest%0Aimport types%0A%0Afrom aiozk.exc import TimeoutError%0Afrom aiozk.states import States%0A%0Alog = logging.getLogger(__name__)%0A%0A%0A@pytest.mark.asyncio%0Aasync def test_creation_failure_deadlock(zk, path):%0A    lock = zk.recipes.Lock(path)%0A    await lock.ensure_path()%0A%0A    async def change_state():%0A        await asyncio.sleep(1)%0A        zk.session.state.transition_to(States.SUSPENDED)%0A%0A    async def create(self, *args, **kwargs):%0A        await self.create_orig(*args, **kwargs)%0A        # SHOULD NOT REACH HERE%0A%0A    zk.create_orig = zk.create%0A    zk.create = types.MethodType(create, zk)%0A%0A    zk.session.conn.read_loop_task.cancel()%0A    zk.session.conn.read_loop_task = None%0A    # wait for that read loop task is cancelled%0A    await asyncio.sleep(1)%0A%0A    asyncio.create_task(change_state())%0A    lock_acquired = False%0A    with pytest.raises(TimeoutError):%0A        async with await lock.acquire(timeout=2):%0A            lock_acquired = True%0A%0A    assert not lock_acquired%0A    assert not lock.owned_paths%0A%0A    zk.create = zk.create_orig%0A%0A    lock2 = zk.recipes.Lock(path)%0A    try:%0A        async with await lock2.acquire(timeout=2):%0A            lock_acquired = True%0A%0A        assert lock_acquired%0A    finally:%0A        await zk.deleteall(path)%0A

add test code for deadlock incurred by znode creation failure.