self._fds = {}
self._timeout = None
- try:
- self._socket_action = self._multi.socket_action
- except AttributeError:
- # socket_action is found in pycurl since 7.18.2 (it's been
- # in libcurl longer than that but wasn't accessible to
- # python).
- gen_log.warning("socket_action method missing from pycurl; "
- "falling back to socket_all. Upgrading "
- "libcurl and pycurl will improve performance")
- self._socket_action = \
- lambda fd, action: self._multi.socket_all()
-
# libcurl has bugs that sometimes cause it to not report all
# relevant file descriptors and timeouts to TIMERFUNCTION/
# SOCKETFUNCTION. Mitigate the effects of such bugs by
action |= pycurl.CSELECT_OUT
while True:
try:
- ret, num_handles = self._socket_action(fd, action)
+ ret, num_handles = self._multi.socket_action(fd, action)
except pycurl.error as e:
ret = e.args[0]
if ret != pycurl.E_CALL_MULTI_PERFORM:
self._timeout = None
while True:
try:
- ret, num_handles = self._socket_action(
+ ret, num_handles = self._multi.socket_action(
pycurl.SOCKET_TIMEOUT, 0)
except pycurl.error as e:
ret = e.args[0]
"callback": callback,
"curl_start_time": time.time(),
}
- # Disable IPv6 to mitigate the effects of this bug
- # on curl versions <= 7.21.0
- # http://sourceforge.net/tracker/?func=detail&aid=3017819&group_id=976&atid=100976
- if pycurl.version_info()[2] <= 0x71500: # 7.21.0
- curl.setopt(pycurl.IPRESOLVE, pycurl.IPRESOLVE_V4)
_curl_setup_request(curl, request, curl.info["buffer"],
curl.info["headers"])
self._multi.add_handle(curl)
if request.allow_ipv6 is False:
# Curl behaves reasonably when DNS resolution gives an ipv6 address
# that we can't reach, so allow ipv6 unless the user asks to disable.
- # (but see version check in _process_queue above)
curl.setopt(pycurl.IPRESOLVE, pycurl.IPRESOLVE_V4)
else:
curl.setopt(pycurl.IPRESOLVE, pycurl.IPRESOLVE_WHATEVER)
* ``curl_httpclient`` was the default prior to Tornado 2.0.
-Note that if you are using ``curl_httpclient``, it is highly recommended that
-you use a recent version of ``libcurl`` and ``pycurl``. Currently the minimum
-supported version is 7.18.2, and the recommended version is 7.21.1 or newer.
-It is highly recommended that your ``libcurl`` installation is built with
-asynchronous DNS resolver (threaded or c-ares), otherwise you may encounter
-various problems with request timeouts (for more information, see
+Note that if you are using ``curl_httpclient``, it is highly
+recommended that you use a recent version of ``libcurl`` and
+``pycurl``. Currently the minimum supported version of libcurl is
+7.21.1, and the minimum version of pycurl is 7.18.2. It is highly
+recommended that your ``libcurl`` installation is built with
+asynchronous DNS resolver (threaded or c-ares), otherwise you may
+encounter various problems with request timeouts (for more
+information, see
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCONNECTTIMEOUTMS
and comments in curl_httpclient.py).
+
"""
from __future__ import absolute_import, division, print_function, with_statement