Switch a few of the buildman methods to coroutines in order to support network calls in methods. Add a test for the ephemeral build manager.

This commit is contained in:
Jake Moshenko 2014-12-22 12:14:16 -05:00
parent a280bbcb6d
commit 12ee8e0fc0
11 changed files with 233 additions and 52 deletions

View file

@ -5,7 +5,7 @@ from buildman.component.basecomponent import BaseComponent
from buildman.component.buildcomponent import BuildComponent
from buildman.manager.basemanager import BaseManager
from trollius.coroutines import From
from trollius.coroutines import From, Return, coroutine
REGISTRATION_REALM = 'registration'
logger = logging.getLogger(__name__)
@ -50,14 +50,15 @@ class EnterpriseManager(BaseManager):
self.register_component(realm, BuildComponent, token="")
return realm
@coroutine
def schedule(self, build_job, loop):
""" Schedules a build for an Enterprise Registry. """
if self.shutting_down or not self.ready_components:
return False
raise Return(False)
component = self.ready_components.pop()
loop.call_soon(component.start_build, build_job)
return True
raise Return(True)
def build_component_ready(self, build_component, loop):
self.ready_components.add(build_component)
@ -65,6 +66,7 @@ class EnterpriseManager(BaseManager):
def shutdown(self):
self.shutting_down = True
@coroutine
def job_completed(self, build_job, job_status, build_component):
self.job_complete_callback(build_job, job_status)