Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Minimum connections #9

Open
rdrey opened this issue Sep 23, 2016 · 0 comments
Open

Feature request: Minimum connections #9

rdrey opened this issue Sep 23, 2016 · 0 comments

Comments

@rdrey
Copy link
Contributor

rdrey commented Sep 23, 2016

I currently instantiate my pool like this:

class EPPPool(ConnectionPool):
    def _new_connection(self):
        try:
            return EPPSession(self.config)
        except Exception as e:
            # If the pool fails to start or gets too small, quit
            if len(self.conn) < self.size / 2:
                logging.error("Pool unhealthy, quitting")
                os.kill(os.getpid(), signal.SIGTERM)
            raise e

this works fine, but technically I'd like the pool to die while it's getting constructed (and not asynchronously).

I would like to propose a minimum_size, which gets created synchronously in
ConnectionPool.__init__. The minimum number of connections could be created immediately (self._addOne()) and the constructor would raise an exception if creating them fails, then the remaining size - minimum_size connections get created as usual (gevent.spawn_later(self.SPAWN_FREQUENCY*i, self._addOne)).

How do you feel about this change? It's pretty small and restricted to ConnectionPool.__init__.

Thanks, great little module!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant