[Twisted-Python] serializing inline callbacks
Axel Rau
Axel.Rau at chaos1.de
Tue Feb 18 14:58:18 MST 2014
Am 18.02.2014 um 20:03 schrieb Dustin J. Mitchell <dustin at v.igoro.us>:
> I'm suggesting that there are lots more problems with your code than
> the one you have identified. Any method which is decorated with
Sure. This is my 1st project with twisted. (-;
> @defer.inlineCallbacks will return a Deferred,
This is the missing clue.
> and you need to handle
> every Deferred somehow. Generally (although not always, as lvh has
> said) you do that by yielding it.
>
> Your code should be
I have that implemented, but B does not call C:
>
> ----
> def render_GET(self, request):
> ...
> d = self.A()
> d.addErrback(request.processingFailed)
> return NOT_DONE_YET
>
> @inlineCallbacks
> def A(self):
> ...
> tmp = yield subprocess(args)
> ...
> yield self.B()
>
> @inlineCallbacks
> def B(self):
> ...
> tmp = yield subprocess(args)
> ...
> yield self.C()
> =====================================> stops here
> def C(self):
> ...
> x = yield self.D(...)
> y = yield self.D(...)
> z = yield self.D(...)
> ...
> yield self.E()
>
> @inlineCallbacks
> def D(self):
> ...
> tmp = yield subprocess(args)
> ...
> returnValue(tmp)
>
>
> @inlineCallbacks
> def E(self):
> ...
> tmp = yield subprocess(args)
> ...
> request.write(...)
> request.finished()
>
> ----
>
> Here you see that all of the Deferreds are handled, either by yielding
> them or, in the case of the Deferred from A, by adding an errback that
> will conveniently format an HTML error response.
This is B:
- - - -
@inlineCallbacks
def imageMap(self):
"""
return client side image maps
"""
args = list(self.basecmd)
args.extend((
'-g', conf.graphlist[self.station][0], '-I', '-m', '-d', '-d', '-d', '-d'))
map = yield util.subprocess(args)
self.request.write(bytes(map))
yield self.navigation()
if debug: log.msg('imageMap ended')
- - - -
and begin of C:
- - - -
def navigation(self):
"""
Compute links for navigation (up, left, right arrows or)
week, month, year) and place them on the page.
"""
if debug: log.msg('In navigation.'). . .
- - - -
I see log message ‚imageMap ended‘ , but not 'In navigation.'
Any further advice?
Thanks for your patience,
Axel
---
PGP-Key:29E99DD6 ☀ +49 151 2300 9283 ☀ computing @ chaos claudius
More information about the Twisted-Python
mailing list