2
0
mirror of https://github.com/openvswitch/ovs synced 2025-09-03 15:55:19 +00:00

windows, python: Remove code duplication in send/recv functions

Move the return value at the end of the function
regardless of the pending/non-pending operation.

Signed-off-by: Alin Balutoiu <abalutoiu@cloudbasesolutions.com>
Acked-by: Russell Bryant <russell@ovn.org>
Acked-by: Alin Gabriel Serdean <aserdean@ovn.org>
Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
This commit is contained in:
Alin Balutoiu
2017-08-22 10:47:24 +00:00
committed by Alin Gabriel Serdean
parent e2e31d17f8
commit ba953e1e83

View File

@@ -321,11 +321,6 @@ class Stream(object):
self._read,
False)
self._read_pending = False
recvBuffer = self._read_buffer[:nBytesRead]
# recvBuffer will have the type memoryview in Python3.
# We can use bytes to convert it to type bytes which works on
# both Python2 and Python3.
return (0, bytes(recvBuffer))
except pywintypes.error as e:
if e.winerror == winutils.winerror.ERROR_IO_INCOMPLETE:
# The operation is still pending, try again
@@ -336,6 +331,7 @@ class Stream(object):
return (0, "")
else:
return (errno.EINVAL, "")
else:
(errCode, self._read_buffer) = winutils.read_file(self.pipe,
n,
self._read)
@@ -406,7 +402,6 @@ class Stream(object):
self._write,
False)
self._write_pending = False
return nBytesWritten
except pywintypes.error as e:
if e.winerror == winutils.winerror.ERROR_IO_INCOMPLETE:
# The operation is still pending, try again
@@ -417,8 +412,7 @@ class Stream(object):
return -errno.ECONNRESET
else:
return -errno.EINVAL
self._write_pending = False
else:
(errCode, nBytesWritten) = winutils.write_file(self.pipe,
buf,
self._write)