簡體   English   中英

使用tornado.httpclient下載-非阻塞Python

[英]Download using tornado.httpclient — Non-blocking Python

def handle_request(param1,param2):
    if response.error:
        print "Error:", response.error
    else:
        print response.body
        print param1
        print param2


param1
param2
http_client = AsyncHTTPClient()
http_client.fetch("http://www.google.com/", handle_request)

我需要將param1和param2傳遞給handle_request

使用functools.partial

import functools

# handle_response will be called with three arguments:
# first the ones from the partial, and then the response
def handle_response(param1, param2, response): pass

http_client.fetch("http://www.google.com",
    functools.partial(handle_request, param1, param2))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM