Hi guys
My Email: jakezhang1989@hotmail.com
My GitHub Link
Thank you for taking time to go through this post from which you would get what you want.
If you have any problems or opinions that are different form mins, please email me or leave a comments. I will reply as soon as possible.
OK, Let us get started!
What is Deferred
Deferred is a type of object designed to do one thing only:
encode the execution order as callback-based and separately from the normal order of the python source codes.
What does and not does
It does not deal with threads, parallelism, signals or subprocesses.
It does not no know anything about an event loop, green lets or scheduling.
All it knows is what order to do things that we explicitly tell it the order we want.
Thus, instead of writing:
door.open();
pad.launch();
We write:
d = door.open();
d.addCallBack(pad.launch);
Summary
- Do something after an asynchronous operation completes successfully
- Use the result of a successful asynchronous operation
- Catch errors in asynchronous operations
- Do one thing if an operation succeeds, and a different thing if it fails
- Do something after an error has been handled successfully
- Wrap multiple asynchronous operations with one error handler
- Do something after an asynchronous operation, regardless of whether it succeeded or failed
- Write code without callbacks using inline Callbacks