Created
July 23, 2016 13:47
-
-
Save zhangclb/7e173a40ce7dcfef6645c894811593c8 to your computer and use it in GitHub Desktop.
uliweb gevent race condition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~$ prun "t1: curl -s localhost:8000/t1?v=1" "t2: curl -s localhost:8000/t2?v=2" | |
1 t1: curl -s localhost:8000/t1?v=1 | |
2 t2: curl -s localhost:8000/t2?v=2 | |
t2: t2: v=2, v_after_sleep=1 | |
t2: --- end --- | |
t1: t1: v=1, v_after_sleep=1 | |
t1: --- end --- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding=utf-8 | |
from uliweb import expose, functions | |
import gevent | |
@expose('/t1') | |
def t1(): | |
v = request.values.get("v") | |
gevent.sleep(5) | |
v_after_sleep = request.values.get("v") | |
return 't1: v=%s, v_after_sleep=%s\n'%(v,v_after_sleep) | |
@expose('/t2') | |
def t2(): | |
v = request.values.get("v") | |
gevent.sleep(1) | |
v_after_sleep = request.values.get("v") | |
return 't2: v=%s, v_after_sleep=%s\n'%(v,v_after_sleep) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment