Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3069eec

Browse files
author
meig
committed
fix AsyncSession bug
1 parent6dac96b commit3069eec

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

‎pub/session/session.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def report(self):
7272

7373
classAsyncSession(Session):
7474
def__init__(self):
75-
self.__last_handler=None
75+
Session.__init__(self)
7676

7777
classResponseFilter(object):
7878
def__init__(self,handler,filter):
@@ -94,7 +94,7 @@ def fetch(self,url,method,headers,body,response_handler,connect_timeout=10,reque
9494
req=_create_request(self._cookie_stg,url,method,headers,body,connect_timeout,request_timeout)
9595
client=tornado.httpclient.AsyncHTTPClient()
9696
handler=self.ResponseFilter(response_handler,self._filter_response)
97-
client.fetch(req,handler)
97+
client.fetch(req,handler.handle_response)
9898
returnTrue
9999

100100
defsend_form(self,action,method,data_map,reponse_handler,connect_timeout=10,request_timeout=10):

‎pub/session/test.py‎

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
importsession
2+
importtornado.ioloop
23

34

45
browser=session.Session()
@@ -9,26 +10,9 @@ def handle_response(response):
910

1011

1112
if__name__=="__main__":
12-
forurlin ("http://mail.163.com/","http://dev.anzhi.com/","http://www.taobao.com/","http://music.baidu.com","http://mail.sogou.com/"):
13-
print"Sync GET: ",url
14-
browser.fetch(url,"GET",{},None)
15-
browser.report()
16-
17-
1813
print"login sogou mail :"
1914
action="https://account.sogou.com/web/login"
2015
data= {"username":"game_works_002","password":"abc123","client_id":"1014","xd":"http://mail.sogou.com/jump.htm"}
21-
resp=browser.send_form(action,"POST",data)
22-
printresp.body
23-
browser.report()
24-
25-
url="http://mail.sogou.com/bapp/7/main"
26-
resp=browser.fetch(url,"GET",{},None)
27-
printresp.body
28-
print"fetch game_works_002:"
29-
printresp.body.find("game_works_002")!=-1
30-
browser.report()
31-
32-
raw_input("press")
16+
async_browser.send_form(action,"POST",data,handle_response)
17+
tornado.ioloop.IOLoop.instance().start()
3318

34-

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp