pyArango
pyArango copied to clipboard
When using gevent/greenlets, highly concurrent requests can return incorrect responses
When sending multiple concurrent requests through gevent/greenlets, requests from one greenlet can sometimes leak their state into other greenlets. So a request will get the response from a different query.
This may be related to a similar issue, under the same circumstances where a "Bad Status Line" exception is thrown when reading a response. Doing a TCPDump shows that the data coming across the wire is correct, but pyArango seems to drop portions of the incoming stream.
I am not familiar with greenlets, but if all threads are behind the same connection query results might get swaped. You could try having several connections, running each query in a different processes instead of threads or you could implement a way to associate each thread to the right result by having them share a lookup table of results.
Meanwhile we found out that one needs to use the gevent based http client in order to make this work. Monkey patching the Aikido-session can do the trick.
Hi @bkp-billy @tariqdaouda @dothebart , I have fixed it by using a different session for each request and also implemented, fixed connection for concurrent requests through gevent/greenlets Check out the fork at dilipvamsi/pyArango/tree/origin/geevent
Regards, Dilip Vamsi.
Hi @bkp-billy @tariqdaouda @dothebart ,
As the request.Session
is not thread safe it is better to create a session for each request rather than using the same request which fixes everything.