此defer非golang中的defer https://tour.golang.org/flowcontrol/12

from twitter.common.concurrent import Timeout, deadline, defer
from twitter.common.quantity import Amount, Time
import time def _stop():
print 'stop begin'
time.sleep(7)
print 'stop done' def stop():
defer(_stop) deadline(stop, timeout= Amount(3, Time.SECONDS), daemon=True, propagate=True)

这个代码是不会抛出exception的,twitter中defer主要用途是并发启动一些命令,不会相互block。

refer to: https://github.com/twitter/commons/tree/master/src/python/twitter/common/concurrent

twitter.common.concurrent deadline and defer的更多相关文章

  1. Twitter的分布式系统中ID生成方法——Snowflake

    Twitter-Snowflake算法产生的背景相当简单,为了满足Twitter每秒上万条消息的请求,每条消息都必须分配一条唯一的id,这些id还需要一些大致的顺序(方便客户端排序),并且在分布式系统 ...

  2. Concurrent.Thread.js

    (function(){ if ( !this.Data || (typeof this.Data != 'object' && typeof this.Data != 'functi ...

  3. Awesome Go

    A curated list of awesome Go frameworks, libraries and software. Inspired by awesome-python. Contrib ...

  4. Go 语言相关的优秀框架,库及软件列表

    If you see a package or project here that is no longer maintained or is not a good fit, please submi ...

  5. Awesome Go (http://awesome-go.com/)

    A curated list of awesome Go frameworks, libraries and software. Inspired by awesome-python. Contrib ...

  6. Effective Scala

    Effective Scala Marius Eriksen, Twitter Inc.marius@twitter.com (@marius)[translated by hongjiang(@ho ...

  7. 【原创】ui.router源码解析

    Angular系列文章之angular路由 路由(route),几乎所有的MVC(VM)框架都应该具有的特性,因为它是前端构建单页面应用(SPA)必不可少的组成部分. 那么,对于angular而言,它 ...

  8. ScheduledExecutorService定时周期执行指定的任务

    示例代码 package com.effective.common.concurrent.execute; import java.text.DateFormat; import java.text. ...

  9. angular.js的ui-router总结

     ui-route     先有个网址,再在这个网址下写路由   子路由的搭建   我们的布局/模板文件 index.html 我们通过建立一个主文件来引入我们所需要的所有资源以开始我们的项目 ,这里 ...

随机推荐

  1. UvaLA 3938 "Ray, Pass me the dishes!"

                            "Ray, Pass me the dishes!" Time Limit: 3000MS   Memory Limit: Unkn ...

  2. JS 初级(三)接上

    传送门 http://www.cnblogs.com/Sabo-dudu/p/5788197.html 现阶段我就了解了这么多,在以后的学习中,我会不断的更新,如果有什么不同的见解可以一块学习,谁有更 ...

  3. WebForm控件--2016年12月29日

    简单控件 1.Label  =>   <span id="Label1">Label1</span> 2.Literal  =>  Text 填 ...

  4. Data scientist———java实现常见的机器学习代码(跟百度深度学习研究院师兄学机器学习)

    2016-05-02开始决定好好记录一切有关<数据科学家>的学习过程.记录学习笔记. --------------------------------------------------- ...

  5. 【Tomcat】配置Tomcat

    写这篇博文的原因:因为发布Maven项目的时候,始终无法访问.所以顺便重新配置了Tomcat. 1.首先到官网下载一个Tomcat7版本的zip包,解压后,放入C盘(根据个人需求放置). 2.修改co ...

  6. Python之Web框架

    Python之Web框架: 一.  Web框架的本质: 对于所有的Web应用,本质上其实就是一个socket服务端,用户的浏览器其实就是一个socket客户端. #!/usr/bin/env pyth ...

  7. ng-repeat

    <html ng-app="compile"> <head> <script src="http://apps.bdimg.com/libs ...

  8. cell单选

    先上图给看看效果 cell单选逻辑就是取出上一个选中的cell 设置图片为默认图片 在取出点击的cell 设置图片为选中图片即可 废话不多说直接上代码 p.p1 { margin: 0.0px 0.0 ...

  9. Linux 安装Mono环境 运行ASP.NET(二)

    一.安装libgdiplus     前面我们已经安装了apr.apr_util.pcre和httpd apache .现在我们来安装libgdiplus Libgdiplus是一个Mono库,用于对 ...

  10. iOS UIButton 设置图片平铺

    UIImage *image2 = [UIImage imageNamed:imgName]; CGFloat top = ; // 顶端盖高度 CGFloat bottom = ; // 底端盖高度 ...