]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
add greenthread.sleep to increase yields
authorMark McClain <mark.mcclain@dreamhost.com>
Wed, 2 Oct 2013 20:51:33 +0000 (16:51 -0400)
committerMark McClain <mark.mcclain@dreamhost.com>
Wed, 2 Oct 2013 21:00:25 +0000 (17:00 -0400)
This is a stopgap Havana release.  Add eventlet greenthread.sleep to
increase thread yields.

Partially fixes: 1230407
Partially fixes: 1224001

Change-Id: I18953cf8e457ebb33780817582b4788fb5ed6f73

neutron/db/agents_db.py

index 3e4ce5ea2007d63875a4153d47f207c1c02d1f4a..d04f7faf56bb329a48301d3950c536c5ddd55f5e 100644 (file)
@@ -15,6 +15,8 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+from eventlet import greenthread
+
 from oslo.config import cfg
 import sqlalchemy as sa
 from sqlalchemy.orm import exc
@@ -146,14 +148,18 @@ class AgentDbMixin(ext_agent.AgentPluginBase):
                 res['heartbeat_timestamp'] = current_time
                 if agent.get('start_flag'):
                     res['started_at'] = current_time
+                greenthread.sleep(0)
                 agent_db.update(res)
             except ext_agent.AgentNotFoundByTypeHost:
+                greenthread.sleep(0)
                 res['created_at'] = current_time
                 res['started_at'] = current_time
                 res['heartbeat_timestamp'] = current_time
                 res['admin_state_up'] = True
                 agent_db = Agent(**res)
+                greenthread.sleep(0)
                 context.session.add(agent_db)
+            greenthread.sleep(0)
 
 
 class AgentExtRpcCallback(object):