【问题标题】:Pycurl perform() method, writefunc execution modelPycurl perform() 方法,writefunc 执行模型
【发布时间】:2012-01-26 00:57:07
【问题描述】:
当 pycurl 执行它的 perform() 方法时,
Python脚本是等到它被执行(WRITEFUNCTION)还是python
即使没有输入 WRITEFUNCTION 或没有返回结果,是否立即进入下一行?
例如
curl.setopt(pycurl.WRITEFUNCTION, receive)
curl.perform()
some_call() # is this line immeditely executed? can I expect receive() has already exited?
【问题讨论】:
标签:
python
http
curl
libcurl
【解决方案1】:
pycurl 是 C 实现 (libcurl) 的包装器,C 实现在执行其 curl_easy_perform 或 curl_multi_perform 函数(相当于 pycurl perform)期间调用其 WRITEFUNCTION 回调。
所以你可以期待你的回调在perform 返回之前完成。即,您可以期望 some_call () 在receive 完成后执行。