import asyncio


async def orchestrate(lock):
    async with asyncio.TaskGroup() as tg:
        tg.create_task(process_item())

    async with lock:
        state = next_state()

    await persist_state(state)

    delay = 1
    for attempt in range(3):
        try:
            return await run_job()
        except RuntimeError:
            await asyncio.sleep(delay)
            delay *= 2