twitter.common.concurrent deadline and defer
此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的更多相关文章
- Twitter的分布式系统中ID生成方法——Snowflake
Twitter-Snowflake算法产生的背景相当简单,为了满足Twitter每秒上万条消息的请求,每条消息都必须分配一条唯一的id,这些id还需要一些大致的顺序(方便客户端排序),并且在分布式系统 ...
- Concurrent.Thread.js
(function(){ if ( !this.Data || (typeof this.Data != 'object' && typeof this.Data != 'functi ...
- Awesome Go
A curated list of awesome Go frameworks, libraries and software. Inspired by awesome-python. Contrib ...
- Go 语言相关的优秀框架,库及软件列表
If you see a package or project here that is no longer maintained or is not a good fit, please submi ...
- Awesome Go (http://awesome-go.com/)
A curated list of awesome Go frameworks, libraries and software. Inspired by awesome-python. Contrib ...
- Effective Scala
Effective Scala Marius Eriksen, Twitter Inc.marius@twitter.com (@marius)[translated by hongjiang(@ho ...
- 【原创】ui.router源码解析
Angular系列文章之angular路由 路由(route),几乎所有的MVC(VM)框架都应该具有的特性,因为它是前端构建单页面应用(SPA)必不可少的组成部分. 那么,对于angular而言,它 ...
- ScheduledExecutorService定时周期执行指定的任务
示例代码 package com.effective.common.concurrent.execute; import java.text.DateFormat; import java.text. ...
- angular.js的ui-router总结
ui-route 先有个网址,再在这个网址下写路由 子路由的搭建 我们的布局/模板文件 index.html 我们通过建立一个主文件来引入我们所需要的所有资源以开始我们的项目 ,这里 ...
随机推荐
- PHP 验证码生成类(可定制长度和内容)
===================VerifyTool====================== <?php class VerifyTool { private $fontPath; / ...
- rabbitmq
send端 import pika credentials = pika.PlainCredentials(') connection = pika.BlockingConnection(pika.C ...
- 结合实例详细介绍encodeURI()、encodeURIComponent()、decodeURI()、decodeURIComponent()使用方法
在介绍encodeURI().encodeURIComponent().decodeURI().decodeURIComponent()方法前我们需要了解Global对象的概念: Global(全 ...
- 【Django】--Model字段
参考地址:http://www.cnblogs.com/wupeiqi/articles/6216618.html 所有字段 AutoField(Field) --int自增列,必须填入参数prima ...
- history命令详解
Linux下history命令用法 ^_^在项目中希望调用history命令来获取用户的历史记录,方便分析,可是我们平时所见到的history结果是下面这样: # history | head -10 ...
- hdu 1241 Oil Deposits
#include<cstdio> #include<iostream> #include<algorithm> #include<math.h> #in ...
- C# oracle odp.net 32位/64位版本的问题
问题如下: 系统是win7 64位,技术 asp.net mvc 4, 数据库 oracle 11g. 由于某些原因只能使用 32的 ODP.NET ( Oracle Data Provider ), ...
- 使用Selector改变TextView的字体颜色textColor的方法
先上Selector文件,名字为singer_fragment_top_text_style.xml, <?xml version="1.0" encoding=" ...
- 1Z0-050
QUESTION 13 View the Exhibit.Examine the following command that is executed for the TRANSPORT table ...
- Datazen笔记索引
Datazen介绍 http://www.cnblogs.com/aspnetx/p/4557547.html Datazen安装 http://www.cnblogs.com/aspnetx ...