python: Add ovs_error() helper function to Python.
[sliver-openvswitch.git] / python / ovs / jsonrpc.py
index 25b0229..5f90b39 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2010, 2011 Nicira Networks
+# Copyright (c) 2010, 2011, 2012 Nicira Networks
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -20,9 +20,10 @@ import ovs.poller
 import ovs.reconnect
 import ovs.stream
 import ovs.timeval
+import ovs.util
 import ovs.vlog
 
-EOF = -1
+EOF = ovs.util.EOF
 vlog = ovs.vlog.Vlog("jsonrpc")
 
 
@@ -301,7 +302,10 @@ class Connection(object):
         reply = None
         while not error:
             error, reply = self.recv_block()
-            if reply and reply.type == Message.T_REPLY and reply.id == id_:
+            if (reply
+                and (reply.type == Message.T_REPLY
+                     or reply.type == Message.T_ERROR)
+                and reply.id == id_):
                 break
         return error, reply