[Libguestfs] [PATCH nbdkit] plugins: python: Make threading model explicit

Eric Blake eblake at redhat.com
Tue Feb 1 15:39:48 UTC 2022


On Tue, Feb 01, 2022 at 04:20:29PM +0200, Nir Soffer wrote:
> The default threading model is already serializing all requests, but
> implementing thread_model() gives us good place to explain why the code
> works and why we don't use os.preadv and os.pwritev.

And protects us if we ever relax the python plugin to default to a
more parallel model (although more likely, we would make it where we
still default to serial, but clients can opt in to more parallel, the
way we did when we added parallel support to the sh bindings)

>  
> +def thread_model():
> +    # Serialize all requests so we can seek safely in pread and pwrite
> +    # and be compatible with python 3.6. In python 3.7 we can use
> +    # os.preadv and os.pwritev and use the parallel threading model.
> +    return nbdkit.THREAD_MODEL_SERIALIZE_ALL_REQUESTS

ACK

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org




More information about the Libguestfs mailing list