From c2b52c6efc3b6b4f0eae05e1d3136d93acbde99a Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Tue, 22 Nov 2016 16:43:32 -0500 Subject: [PATCH] wrap build_complete coroutine in callback Coroutines cannot be called as callbacks for Futures like the one returned by our RPC call. We work around this by creating a normal function that schedules the coroutine. --- buildman/component/buildcomponent.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/buildman/component/buildcomponent.py b/buildman/component/buildcomponent.py index d453949ef..1f4d364ae 100644 --- a/buildman/component/buildcomponent.py +++ b/buildman/component/buildcomponent.py @@ -157,7 +157,14 @@ class BuildComponent(BaseComponent): logger.debug('Invoking build: %s', self.builder_realm) logger.debug('With Arguments: %s', build_arguments) - self.call("io.quay.builder.build", **build_arguments).add_done_callback(self._build_complete) + def build_complete_callback(result): + """ This function is used to execute a coroutine as the callback. """ + @trollius.coroutine + def closure(): + yield From(self._build_complete(result)) + trollius.ensure_future(closure()) + + self.call("io.quay.builder.build", **build_arguments).add_done_callback(build_complete_callback) # Set the heartbeat for the future. If the builder never receives the build call, # then this will cause a timeout after 30 seconds. We know the builder has registered