Re:Escape from Callback Hell: Callbacks are the modern goto
by pjscott on Saturday November 03, 2012 @12:56AM
(#4735940)
That looks like an unnecessarily confusing way of writing this code:
That's the code I would write if I were using Eventlet or Gevent, and it would work just fine. Why settle for less? It's 2012, damn it; we shouldn't have to dick around with deferreds except under exotic circumstances.
[ Parent
| on HN ]
Re:Escape from Callback Hell: Callbacks are the modern goto
by zenbot on Saturday November 03, 2012 @10:11AM
(#4736631)
This is possible in Twisted, using inline callbacks:
try:
data = doManyFancyThingsWith(yield asyncResult())
print 'Parsed data:', data
except:
print 'Oh no, something went wrong!'
I find that I use inline callbacks for the common case and work with deferreds directly only when it makes more sense to handle callbacks explicitly.