elastic / elasticsearch-py

Official Python client for Elasticsearch
https://ela.st/es-python
Apache License 2.0
4.21k stars 1.18k forks source link

Requests timeout for Elasticsearch.mtermvectors() method #395

Closed ApproximateIdentity closed 8 years ago

ApproximateIdentity commented 8 years ago

I'm using elasticsearch-py version 2.2.0 (which matches my server).

How do I change the default connection timeout of 10 seconds to something longer for the Elasticsearch.mtermvectors() method? It seems to me the problem is not an es timeout, but a timeout in the underlying urllib3 module. I don't see anything in the documentation:

http://elasticsearch-py.readthedocs.org/en/master/api.html#elasticsearch.Elasticsearch.mtermvectors

I've also tried just passing in a timeout parameter, but that isn't recognized. Here is the important part of the stack trace (though I don't think it really helps much):

  File "/home/twn/data_gen/venv/local/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 69, in _wrapped
    return func(*args, params=params, **kwargs)
  File "/home/twn/data_gen/venv/local/lib/python2.7/site-packages/elasticsearch/client/__init__.py", line 1053, in mtermvectors
    doc_type, '_mtermvectors'), params=params, body=body)
  File "/home/twn/data_gen/venv/local/lib/python2.7/site-packages/elasticsearch/transport.py", line 329, in perform_request
    status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File "/home/twn/data_gen/venv/local/lib/python2.7/site-packages/elasticsearch/connection/http_urllib3.py", line 99, in perform_request
    raise ConnectionTimeout('TIMEOUT', str(e), e)
ConnectionTimeout: ConnectionTimeout caused by - ReadTimeoutError(HTTPConnectionPool(host='localhost', port=9200): Read timed out. (read timeout=10))
ApproximateIdentity commented 8 years ago

Of course I figure it out after posting this that the correct flag is request_timeout. I couldn't find this in the docs, but if I pass in request_timeout=20 I can drop in with a debugger and verify at that point that the timeout does get set to 20. So I'm going to go ahead and close this.

honzakral commented 8 years ago

Leaving here in case anyone has the same issue - it's documented in the Global Options part of the API docs: http://elasticsearch-py.readthedocs.org/en/master/api.html#timeout