[Twisted-Python] Some things I've learned: safer callbacks, better t.p.context

Itamar Turner-Trauring itamar at itamarst.org
Tue Oct 18 06:50:10 MDT 2016


Not been doing much Twisted lately, but have been doing async stuff
elsewhere, and I've learned some useful things.

1. Callbacks should be sync or async, but never
sometimes-one-sometimes-the-other. For details go read
http://blog.ometer.com/2011/07/24/callbacks-synchronous-and-asynchronous/.
For example, Deferred.addCallback(f) really should never run f()
immediately.

3. By instrumenting all callbacks it manages, which may or may not
require item #1, Twisted can have a context that automatically follows
callbacks. Node has this and it is extremely useful.
http://fredkschott.com/post/2014/02/conquering-asynchronous-context-with-cls/
is best summary I've found with a bit of searching.

-- 
Itamar Turner-Trauring



More information about the Twisted-Python mailing list