File: multi_setopt.rst

package info (click to toggle)
pycurl 7.45.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,752 kB
  • sloc: python: 8,663; ansic: 6,891; makefile: 202; sh: 183
file content (38 lines) | stat: -rw-r--r-- 1,438 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
setopt(option, value) -> None

Set curl multi option. Corresponds to `curl_multi_setopt`_ in libcurl.

*option* specifies which option to set. PycURL defines constants
corresponding to ``CURLMOPT_*`` constants in libcurl, except that
the ``CURLMOPT_`` prefix is replaced with ``M_`` prefix.
For example, ``CURLMOPT_PIPELINING`` is
exposed in PycURL as ``pycurl.M_PIPELINING``. For convenience, ``CURLMOPT_*``
constants are also exposed on CurlMulti objects::

    import pycurl
    m = pycurl.CurlMulti()
    m.setopt(pycurl.M_PIPELINING, 1)
    # Same as:
    m.setopt(m.M_PIPELINING, 1)

*value* specifies the value to set the option to. Different options accept
values of different types:

- Options specified by `curl_multi_setopt`_ as accepting ``1`` or an
  integer value accept Python integers, long integers (on Python 2.x) and
  booleans::

    m.setopt(pycurl.M_PIPELINING, True)
    m.setopt(pycurl.M_PIPELINING, 1)
    # Python 2.x only:
    m.setopt(pycurl.M_PIPELINING, 1L)

- ``*FUNCTION`` options accept a function. Supported callbacks are
  ``CURLMOPT_SOCKETFUNCTION`` AND ``CURLMOPT_TIMERFUNCTION``. Please refer to
  the PycURL test suite for examples on using the callbacks.

Raises TypeError when the option value is not of a type accepted by the
respective option, and pycurl.error exception when libcurl rejects the
option or its value.

.. _curl_multi_setopt: https://curl.haxx.se/libcurl/c/curl_multi_setopt.html