Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

Maxconnection now just limits the concurrent connections to mongodb inst... #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ceymard
Copy link

@ceymard ceymard commented Apr 2, 2012

...ead of raising an exception when the maxconnections are reached.

As the title of the commit says, I modified ConnectionPool and Cursor so that when reaching the maxconnections, instead of raising an Exception, we just queue the requests in the connectionpool.

Whenever a connection goes back into the cache, the backlog of requests is checked, and if not empty, a (now) free connection is given to the leftmost callback in the backlog.

I did this patch because I ran into a file descriptor limit problem while using asyncmongo.

I have a system wired to RabbitMQ, that sometimes receives ~10000 messages in a few seconds, each of which triggering a request to the MongoDB server. Instead of throttling my own system, I thought it would be interesting to give asyncmongo the possibility of throttling it itself, since I doubt I will be the only one in such a case.

While I removed the raise TooManyConnections altogether, maybe if you prefer, I could add a variable to switch behaviours at will ?

…nstead of raising an exception when the maxconnections are reached.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant