Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PyCon2014China-Zhuhai-bpm.py
Search
Zoom.Quiet
November 17, 2014
Technology
0
66
PyCon2014China-Zhuhai-bpm.py
141115 in Zhuhai
http://zoomq.qiniudn.com/CPyUG/PyCon2014China/141115zh-pm1-bpm.py.MP3
Zoom.Quiet
November 17, 2014
Tweet
Share
More Decks by Zoom.Quiet
See All by Zoom.Quiet
PyCon2014China-Zhuhai-high performance
zoomquiet
0
120
PyCon2014China-Zhuhai-meta programming
zoomquiet
1
91
PyCon2014China-Zhuhai-luna kv db
zoomquiet
0
68
PyCon2014China-Zhuhai-seed studio
zoomquiet
0
46
PyCon2014China-Zhuhai-Docker Registry Build By Python
zoomquiet
0
57
PyCon2014China-Zhuhai-jeff
zoomquiet
0
46
PyCon2014China-Zhuhai-pythonic front-end
zoomquiet
0
61
DevFest2014-Zhuhai-Polymer
zoomquiet
0
310
TEDxJLUZH MOMENT future
zoomquiet
0
270
Other Decks in Technology
See All in Technology
AWS パートナー企業でテクニカルサポートに従事して2年経ったので思うところをまとめてみた
kazzpapa3
3
1.3k
「共通基盤」を超えよ! 今、Platform Engineeringに取り組むべき理由
jacopen
25
5.6k
ビジネスとエンジニアリングの接合点 そしてコード品質がそこに及ぼす影響 v1.1 / The Intersections of Business and Engineering, and The Impact of Code Quality There (v1.1)
mtx2s
11
2.4k
CSSDAY 2024
kevinshallvari
0
180
Oracle Exadata Database Service on Cloud@Customer (ExaDB-C@C) - UI スクリーン・キャプチャ集
oracle4engineer
PRO
1
1.1k
NLP2024 参加報告LT ~RAGの生成評価と懇親戦略~ / nlp2024_attendee_presentation_LT_masuda
taro_masuda
1
190
Let's get started with Ruby && Rails Tips
sinsoku
0
190
Introduction to GKE x LLM
soma00333
0
140
LLM とプロンプトエンジニアリング/チューターをビルドする / LLM and Prompt Engineering and Building Tutors
ks91
PRO
0
200
Hands-on / Kaname Frusawa / Cloud Compare Users Meetup 2024 at University of Tokyo on April 17
paraworld
2
460
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs (QCon London)
inesmontani
PRO
0
140
Tebiki株式会社 エンジニア採用資料
tebiki
0
4k
Featured
See All Featured
Building Effective Engineering Teams - LeadDev
addyosmani
26
1.8k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
60
14k
The Illustrated Children's Guide to Kubernetes
chrisshort
28
46k
The Power of CSS Pseudo Elements
geoffreycrofte
58
5k
Rails Girls Zürich Keynote
gr2m
91
13k
The Mythical Team-Month
searls
214
42k
The Pragmatic Product Professional
lauravandoore
24
5.8k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
15
1.4k
The Brand Is Dead. Long Live the Brand.
mthomps
48
27k
Building an army of robots
kneath
300
41k
Gamification - CAS2011
davidbonilla
76
4.6k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
272
12k
Transcript
None
芯雲流程引擎 使用Python协程解决阻塞问题
[email protected]
Service Orchestration DNS 系统 接入层 系统 告警 系统 配置管理 系统
Game Server SA 系统 IaaS 系统 官网 系统
Python with @task
阻塞问题 result = call_func() result 无法立即获得,所谓“阻塞”
I/O 阻塞 bytes = tcp_socket.recv(4096) 网络I/O操作需要时间,所谓“I/O 阻塞”
例子 连接 发送 接收
回调 def on_received(bytes): ….. def on_sent(sock): sock.recv(on_received) def on_connect(sock): sock.send(‘xxx’,
on_sent) connect(‘a.b.c.d’, on_connect) 上下文
CALLBACK HELL
Logic Locality 最小化开发人员阅读流程代码的眼球移动距离
协程可以表达I/O阻塞 def some_process(): sock = connect(‘a.b.c.d’, on_connect) sock.send(‘xxx’) bytes =
sock.recv(on_received) …. 上下文 locals()
流程阻塞 ip = res.request_new_server(model=’B6’) 调用“外部系统”需要时间,所谓“流程阻塞”
流程阻塞 yes_no = smcs.wechat_approve(‘reboot?’) 人工审批需要时间,所谓“流程阻塞”
协程也可以表达流程阻塞 def some_process(): ip = res.request_new_server(model=’B6’) yes_no = smcs.wechat_approve(‘deploy %s?’
% ip) if yes_no: ijobs.exec_job(‘deploy’, ip)
流程引擎 申请机器 部署 修改DNS 引擎 流程
各式Event Loop 连接 发送 接收 event loop 协程 gevent tulip
/ asyncio tornado evergreen eventlet
所谓Event Loop def some_process(): sock = connect(‘a.b.c.d’, on_connect) sock.send(‘xxx’) bytes
= sock.recv(on_received) …. 协程 Event Loop fd_map = {} [fd, read] => coroutine 操作系统 select kqueue epoll recv好了告诉我, 我先睡你那了 select(sock, EV_READ) fd 132 可读了 fd 132 对应的协程醒醒 开读了
协程可以存数据库的 def some_process(): ip = res.request_new_server(model=’B6’) yes_no = smcs.wechat_approve(‘deploy %s?’
% ip) if yes_no: ijobs.exec_job(‘deploy’, ip) 协程 引擎 event_map = {} event => coroutine 外部系统 审批好了告诉我, 我先睡你那了 wechat approve 审批结果有了 审批好了,协程醒醒 开工了 mysql import cPickle bytes = cPickle.dumps(coroutine)
Python协程实现 • yield • stackless python / pypy • greenlet
/ python-fibers / stacklet / libgevent
Ultimate Coroutine Scheduler • 语言:Java for true parallelism • 协程:co-routine
with bytecode weaver • I/O阻塞:包装NIO • 流程阻塞:event map,持久化可选 https://github.com/taowen/daili
协程大法好 招聘:
[email protected]