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
理解Deferred:一种基于回调的执行顺序编码方式
本文深入探讨了Deferred这一Python对象类型,它专用于编码执行顺序,以回调形式分离并独立于普通Python源代码顺序。通过实例说明,文章解释了如何使用Deferred在异步操作中实现特定的执行顺序,包括成功异步操作后的操作、错误处理、并发操作管理等关键功能。
277

被折叠的 条评论
为什么被折叠?



