Programming Language :: Python :: Understanding Twisted Deferred

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

  1. Do something after an asynchronous operation completes successfully
  2. Use the result of a successful asynchronous operation
  3. Catch errors in asynchronous operations
  4. Do one thing if an operation succeeds, and a different thing if it fails
  5. Do something after an error has been handled successfully
  6. Wrap multiple asynchronous operations with one error handler
  7. Do something after an asynchronous operation, regardless of whether it succeeded or failed
  8. Write code without callbacks using inline Callbacks
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值