diff --git a/NEWS b/NEWS index 84ad8ddf4..5bd49b52e 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,11 @@ Post-v2.15.0 * New command line options --record/--replay for ovsdb-server and ovsdb-client to record and replay all the incoming transactions, monitors, etc. More datails in Documentation/topics/record-replay.rst. + * The Python Idl class now has a cooperative_yield() method that can be + overridden by an application that uses eventlet / gevent / asyncio with + the desired yield method (e.g. {eventlet,gevent,asyncio}.sleep(0)) to + prevent the application from being blocked for a long time while + processing database updates. - In ovs-vsctl and vtep-ctl, the "find" command now accept new operators {in} and {not-in}. - Userspace datapath: diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py index 1bf9b1e09..f24511720 100644 --- a/python/ovs/db/idl.py +++ b/python/ovs/db/idl.py @@ -481,6 +481,15 @@ class Idl(object): :type updates: Row """ + def cooperative_yield(self): + """Hook for cooperatively yielding to eventlet/gevent/asyncio/etc. + + When a block of code is going to spend a lot of time cpu-bound without + doing any I/O, it can cause greenthread/coroutine libraries to block. + This call should be added to code where this can happen, but defaults + to doing nothing to avoid overhead where it is not needed. + """ + def __send_cond_change(self, table, cond): monitor_cond_change = {table.name: [{"where": cond}]} old_uuid = str(self.uuid) @@ -646,6 +655,8 @@ class Idl(object): 'is not an object' % (table_name, uuid_string)) + self.cooperative_yield() + if version == OVSDB_UPDATE2: changes = self.__process_update2(table, uuid, row_update) if changes: