def _begin_write(session: UpdateSession,
                 loop: asyncio.AbstractEventLoop,
                 rootfs_file_path: str):
    """ Start the write process. """
    session.set_progress(0)
    session.set_stage(Stages.WRITING)
    write_future = asyncio.ensure_future(loop.run_in_executor(
        None, file_actions.write_update, rootfs_file_path,
        session.set_progress))

    def write_done(fut):
        exc = fut.exception()
        if exc:
            session.set_error(getattr(exc, 'short', str(type(exc))),
                              str(exc))
        else:
            session.set_stage(Stages.DONE)

    write_future.add_done_callback(write_done)
Start the write process.