Paul Rubin wrote: > But that's just ugly. The fetchPage function should take the > callback as an argument. In an asynchronous system it would even > be buggy.
It won't, in my understanding/experience, since the local context must first terminate before the reactor takes control again and handles other events. Twisted isn't concurrent like using threads here, and adding callbacks immediately after getting a Deferred instance returned is common practice. > What happens if the page fetch completes before you add the > callback? If the Deferred is fired, all already added {call,err}backs will be executed. If you add new ones at this point, they'll be executed immediately. IIRC. http://twistedmatrix.com/projects/core/documentation/howto/async.html http://twistedmatrix.com/projects/core/documentation/howto/defer.html Regards, Björn -- BOFH excuse #12: dry joints on cable plug -- http://mail.python.org/mailman/listinfo/python-list