Pycurl WRITEDATA WRITEFUNCTION 碰撞/崩溃
如何关闭 WRITEFUNCTION 和 WRITEDATA?
使用 pycurl 我有一个名为curlUtil 的类。 其中我有 pageAsString (self, URL) 返回一个字符串。
为此,我设置了 WRITEFUNCTION。 现在在 downloadFile (self, URL, fn, overwrite=0) 中,我做了一个 open 和 self.c.Setopt (pycurl.WRITEFUNCTION, 0) ,这会导致问题。 Int 不是有效的参数。
然后我假设 WRITEDATA 会覆盖该值,或者会有一个 NOWRITEFUNCTION 推荐。 NOWRITEFUNCTION 不存在,所以我只使用 WRITEDATA 并且 Python 崩溃了。
我编写了一个名为reboot()的快速函数,它关闭curl,再次打开它,并调用reset将其置于默认状态。 我在pageAsString和downloadFile中都调用它,完全没有问题。 但是,我不想重新初始化卷曲。 我可能设置了一些特殊选项。
如何关闭 WRITEFUNCTION 和 WRITEDATA?
How do I turnoff WRITEFUNCTION and WRITEDATA?
Using pycurl I have a class call curlUtil. In it I have pageAsString (self, URL) which returns a string.
To do this I setopt WRITEFUNCTION. Now in downloadFile (self, URL, fn, overwrite=0) I do an open and self.c.Setopt (pycurl.WRITEFUNCTION, 0) which cause problems. Int is not a valid argument.
I then assumed WRITEDATA would overwrite the value or there would be a NOWRITEFUNCTION commend. NOWRITEFUNCTION didn't exist so I just used WRITEDATA and Python crashed.
I wrote a quick func called reboot() which closes curl, opens it again, and calls reset to put it in the default state. I call it in both pageAsString and downloadFile and there is no problem at all. But, I don't want to reinitialize curl. There might be some special options I set.
How do I turnoff WRITEFUNCTION and WRITEDATA?
使用 write 函数,而不是关闭它会为你省去很多麻烦。 来重写 pageAsString :
您可能想使用 WRITEFUNCTION..作为示例
using the writefunction, instead of turning it off would save you a lot off trouble. you might want to rewrite your pageAsString by utilizing WRITEFUNCTION..
as an example: