Pycurl perform()方法,writefunc执行模型

时间:2011-12-22 11:04:30

标签: python http curl libcurl

当pycurl执行其perform()方法时, Python脚本是否等待它执行(WRITEFUNCTION)或python 即使没有输入WRITEFUNCTION或没有返回结果,也会立即进入下一行? E.g。

curl.setopt(pycurl.WRITEFUNCTION, receive)
curl.perform()
some_call() # is this line immeditely executed? can I expect receive() has already exited?

1 个答案:

答案 0 :(得分:1)

pycurl是C实现(libcurl)的包装器,C实现在执行curl_easy_performcurl_multi_perform函数期间调用其WRITEFUNCTION回调函数(相当于pycurl {{1} })。

所以你可以期待你的回调在perform返回之前完成执行。即 perform完成后,您可以期待{em}