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
130
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
170
PyCon2014China-Zhuhai-meta programming
zoomquiet
1
160
PyCon2014China-Zhuhai-luna kv db
zoomquiet
0
100
PyCon2014China-Zhuhai-seed studio
zoomquiet
0
120
PyCon2014China-Zhuhai-Docker Registry Build By Python
zoomquiet
0
140
PyCon2014China-Zhuhai-jeff
zoomquiet
0
110
PyCon2014China-Zhuhai-pythonic front-end
zoomquiet
0
140
DevFest2014-Zhuhai-Polymer
zoomquiet
0
440
TEDxJLUZH MOMENT future
zoomquiet
0
400
Other Decks in Technology
See All in Technology
Introduction to Sansan, inc / Sansan Global Development Center, Inc.
sansan33
PRO
0
3k
2026年、サーバーレスの現在地 -「制約と戦う技術」から「当たり前の実行基盤」へ- /serverless2026
slsops
2
260
登壇駆動学習のすすめ — CfPのネタの見つけ方と書くときに意識していること
bicstone
3
120
Frontier Agents (Kiro autonomous agent / AWS Security Agent / AWS DevOps Agent) の紹介
msysh
3
180
20260204_Midosuji_Tech
takuyay0ne
1
160
Greatest Disaster Hits in Web Performance
guaca
0
280
Oracle AI Database移行・アップグレード勉強会 - RAT活用編
oracle4engineer
PRO
0
100
AI駆動開発を事業のコアに置く
tasukuonizawa
1
320
仕様書駆動AI開発の実践: Issue→Skill→PRテンプレで 再現性を作る
knishioka
2
680
Context Engineeringの取り組み
nutslove
0
370
私たち準委任PdEは2つのプロダクトに挑戦する ~ソフトウェア、開発支援という”二重”のプロダクトエンジニアリングの実践~ / 20260212 Naoki Takahashi
shift_evolve
PRO
1
110
AWS Network Firewall Proxyを触ってみた
nagisa53
1
240
Featured
See All Featured
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
190
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.7k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Discover your Explorer Soul
emna__ayadi
2
1.1k
AI: The stuff that nobody shows you
jnunemaker
PRO
2
270
Leo the Paperboy
mayatellez
4
1.4k
The Invisible Side of Design
smashingmag
302
51k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.8k
Code Reviewing Like a Champion
maltzj
527
40k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
350
How to make the Groovebox
asonas
2
1.9k
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]