I am trying to figure out how to make my code more asynchronous using twisted.
- The function returns a pending object.
- then i add a callback list
- the first callback will be called after the deferred function provides some result through
deferred_obj.callback - then in the callback chain the first callback will do something with the data and call the second callback
- etc.
however, chain callbacks will not be considered asynchronous, because they are chained, and the cycle of events will continue to fire at each of them at the same time, until there is more, right?
However, if I have a deferred object, and I add deferred_obj.callback as its callback, as in d.addCallback(deferred_obj.callback), then it will be considered asynchronous because detferred_obj is waiting for data, and then the method that will pass the data is also waiting for data, however, how only the d.callback 'd' object processes the data, then it calls deferred_obj.callback, however, since this object is deferred, unlike random callbacks, it will be executed asynchronously ... correct
Assuming all my code is not blocking, does this mean that chained callbacks are NOT asynchronous, while chained deferrals are correct?
source
share