list index out of range on multithreaded environment
See original GitHub issueHi, first of all, thank you very much for elasticsearch, you are doing a very nice job. This is my first contribution to the community so please be nice with me.
I’m working on a multithreaded enviroment (using multiprocessing.pool.ThreadPool), and sometimes the following error appear:
File "/opt/clustering/wrappers/DAOElasticSearch/DAOElasticSearch.py", line 77, in indexDocument
self.index(index = self.indexName, doc_type = self.docType, body = document, **kwargs)
File "/usr/local/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 69, in _wrapped
return func(*args, params=params, **kwargs)
File "/usr/local/lib/python2.7/site-packages/elasticsearch/client/__init__.py", line 261, in index
_make_path(index, doc_type, id), params=params, body=body)
File "/usr/local/lib/python2.7/site-packages/elasticsearch/transport.py", line 326, in perform_request
connection = self.get_connection()
File "/usr/local/lib/python2.7/site-packages/elasticsearch/transport.py", line 182, in get_connection
return self.connection_pool.get_connection()
File "/usr/local/lib/python2.7/site-packages/elasticsearch/connection_pool.py", line 225, in get_connection
return self.selector.select(self.connections)
File "/usr/local/lib/python2.7/site-packages/elasticsearch/connection_pool.py", line 66, in select
return connections[self.rr]
Is this a problem with my code or is this a bug of elasticsearch client?
Looking over /usr/local/lib/python2.7/site-packages/elasticsearch/connection_pool.py
, I think that this can be solved using some kind of Lock() or Semaphore() protecting connections
variable.
Thanks again, Victor.
Issue Analytics
- State:
- Created 8 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
IndexError: list index out of range error while multithreading
Your problem has nothing to do with multithreading, it's just because results is an empty list. As the comment said, check it's lenght ......
Read more >List Index Out of Range – Python Error [Solved] - freeCodeCamp
This error generally occurs when we try to access an item in a list by using an index that doesn't exist within the...
Read more >DispatchQueue, index out of range, tableView
I can do this multiple times with no crash or index out or range. Only when I put the disptachQueue, it works one...
Read more >List Index out of Range Python for Loop - TutorialAndExample
The List is generally used in Python to store multiple items or elements inside one single variable. The List is ordered in nature,...
Read more >IndexOutOfRangeException Class (System) - Microsoft Learn
The exception that is thrown when an attempt is made to access an element of an array or collection with an index that...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Maybe storing
rr
inthreading.local()
context inRoundRobinSelector
will resolve the issue?Fixed via #539, thanks, @HusainZafar!