Callers to Idl.run() should be able to specify the number of iterations
to run in one call. Instrumentation revealed that a call to Idl.run() with a
can block up to a few seconds, with most of the time being spent parsing
messages.

Since parsing is a CPU only task eventlet and friends are unable to
to provide concurrency. Specifying a configurable number of iterations
will allow calling code to better manage concurrency.

Signed-off-by: Jason Kölker <ja...@koelker.net>
---
 python/ovs/db/idl.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py
index e69d35e..930d92f 100644
--- a/python/ovs/db/idl.py
+++ b/python/ovs/db/idl.py
@@ -140,7 +140,7 @@ class Idl(object):
         update."""
         self._session.close()
 
-    def run(self):
+    def run(self, iterations=50):
         """Processes a batch of messages from the database server.  Returns
         True if the database as seen through the IDL changed, False if it did
         not change.  The initial fetch of the entire contents of the remote
@@ -162,7 +162,7 @@ class Idl(object):
         initial_change_seqno = self.change_seqno
         self._session.run()
         i = 0
-        while i < 50:
+        while i < iterations:
             i += 1
             if not self._session.is_connected():
                 break
-- 
2.7.3

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to