【发布时间】:2019-08-25 14:40:09
【问题描述】:
我正在使用 PycURL 向特定 API 发送多个请求,在我的服务运行之前,我正在使用 PycURL.perform() 发送一个虚拟请求
为了避免打印到我正在使用的控制台中
PycURL.setopt(PycURL.WRITEFUNCTION, noop_write_function)
现在,在我得到响应后,我需要避免写入函数开销,因此我尝试使用 unsetopt(),但它似乎不起作用。
将空值恢复到 WRITEFUNCTION 的良好做法是什么?
部分脚本:
c = pycurl.Curl()
c.setopt(c.URL, 'https://someurl.com')
# send demo http request to open connection with keep alive flag
c.setopt(c.WRITEFUNCTION, noop_write_function)
c.perform()
# actually writing data to bytesIO
buffer = BytesIO()
c.setopt(c.WRITEDATA, buffer)
c.perform()
谢谢, 霍德
【问题讨论】:
标签: python-3.x pycurl