Re: [PATCH 04/10] python: Implement virStreamSend/Recv

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 15, 2011 at 09:23:13PM -0400, Cole Robinson wrote:
> The return values for the python version are different that the C version
> of virStreamSend: on success we return a string, an error raises an exception,
> and if the stream would block we return int(-2). We need to do this
> since strings aren't passed by reference in python.

  I find this a bit bizarre, either we return a string or we return an
integer, but if we don't have any other way to provide the information
Since we provide the wrapper what about returning
  (code#, "string value")
allowing to have only one type on return instead (i.e. just change
recv() in the override below)


> Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx>
> ---
>  python/generator.py                  |    9 +++--
>  python/libvirt-override-virStream.py |   35 +++++++++++++++++++
>  python/libvirt-override.c            |   62 ++++++++++++++++++++++++++++++++++
>  python/typewrappers.c                |   14 ++++++++
>  python/typewrappers.h                |    1 +
>  5 files changed, 117 insertions(+), 4 deletions(-)

> +
> +    def recv(self, nbytes):
> +        """Write a series of bytes to the stream. This method may
> +        block the calling application for an arbitrary amount
> +        of time.
> +
> +        Errors are not guaranteed to be reported synchronously
> +        with the call, but may instead be delayed until a
> +        subsequent call.
> +
> +        On success, the received data is returned. On failure, an
> +        exception is raised. If the stream is a NONBLOCK stream and
> +        the request would block, integer -2 is returned.
> +        """
> +        ret = libvirtmod.virStreamRecv(self._o, nbytes)
> +        if ret == None: raise libvirtError ('virStreamRecv() failed')
> +        return ret

  otherwise looks fine to me,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]