[ovs-dev] [PATCH] python/ovs/stream: TypeError: bad operand type for unary -: 'NoneType'
Isaku Yamahata
yamahata at valinux.co.jp
Wed Nov 21 06:35:48 UTC 2012
This fixes the following exception.
When Stream.__scs_connecting doesn't change self.state, Stream.connect()
returns None as an implicit return value. Then, the following exception
is raised.
I guess this case doesn't happen in unix socket case, but does in TCP socket
case.
> File "ovs/jsonrpc.py", line 306, in transact_block
> error = self.send(request)
> File "ovs/jsonrpc.py", line 240, in send
> self.run()
> File "ovs/jsonrpc.py", line 200, in run
> retval = self.stream.send(self.output)
> File "ovs/stream.py", line 213, in send
> return -retval
> TypeError: bad operand type for unary -: 'NoneType'
Signed-off-by: Isaku Yamahata <yamahata at valinux.co.jp>
---
python/ovs/stream.py | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/python/ovs/stream.py b/python/ovs/stream.py
index c4d243d..b4f5ba6 100644
--- a/python/ovs/stream.py
+++ b/python/ovs/stream.py
@@ -152,9 +152,10 @@ class Stream(object):
assert retval != errno.EINPROGRESS
if retval == 0:
self.state = Stream.__S_CONNECTED
- elif retval != errno.EAGAIN:
- self.state = Stream.__S_DISCONNECTED
+ else:
self.error = retval
+ if retval != errno.EAGAIN:
+ self.state = Stream.__S_DISCONNECTED
def connect(self):
"""Tries to complete the connection on this stream. If the connection
@@ -166,6 +167,11 @@ class Stream(object):
last_state = self.state
if self.state == Stream.__S_CONNECTING:
self.__scs_connecting()
+ if self.state == Stream.__S_CONNECTING:
+ # try again
+ assert self.error == errno.EAGAIN
+ last_state = -1
+ assert self.state != last_state
elif self.state == Stream.__S_CONNECTED:
return 0
elif self.state == Stream.__S_DISCONNECTED:
--
1.7.10.4
More information about the dev
mailing list