which stops the reactor. The trick here is that if you stuff that deferred into a DeferredList before you add the callback that stops the reactor then if your first operation itself returns a deferred, the DeferredList won't call its callbacks until the other Deferred operation completes. So you'll be stacking up a whole bunch of Deferreds inside the first one, and the callback on the DeferredList that does the reactor.stop won't fire until you don't return a Deferred.
There might be an easier way to do this, but this the way I know (example attached). Someone please let me know if there's an easier way. [snip] def render_GET (self, request): self.rq = request target = escape(request.args['target'][0]) d = getPage(target).addCallback(self.print_page) d.addCallback(stopNow) d.addErrback(log.err) return server.NOT_DONE_YET
I'm gonna go ahead and answer my own question here - this isn't restricted to DeferredLists, it applies to regular Deferred's too