0

I'm using PycURL to send multiple request to a specific API, before my service is running I'm sending a dummy request using PycURL.perform()

To avoid printing into the console I'm using

PycURL.setopt(PycURL.WRITEFUNCTION, noop_write_function)

Now after I get a response I need I want to avoid the write function overhead so I'm trying to use unsetopt() but it doesn't seems to work.

Whats the good practice to restore the null value to the WRITEFUNCTION?

Part of the script:

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()

Thanks, Hod

hodisr
  • 314
  • 2
  • 12

1 Answers1

0

WRITEDATA and WRITEFUNCTION cover the same functionality. Note also that depending on Python version and type of argument given to WRITEDATA, WRITEDATA may be converted to a WRITEFUNCTION call.

You could try unsetting both WRITEFUNCTION and WRITEDATA.

D. SM
  • 13,584
  • 3
  • 12
  • 21