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

redis's connection pool makes me wonder #2832

Open
forthcoming opened this issue Jul 5, 2023 · 0 comments
Open

redis's connection pool makes me wonder #2832

forthcoming opened this issue Jul 5, 2023 · 0 comments
Labels

Comments

@forthcoming
Copy link

https://github.com/redis/redis-py/blob/master/redis/connection.py#L1515

def release(self, connection):
    self._checkpid()
    with self._lock:
        try:
            self._in_use_connections.remove(connection)
        except KeyError:
            pass

        if self.owns_connection(connection):
            self._available_connections.append(connection)
        else:
            # pool doesn't own this connection. do not add it back
            # to the pool and decrement the count so that another
            # connection can take its place if needed
            self._created_connections -= 1
            connection.disconnect()
            return

Since you don't own this connection, it means that the program has been fork, and _created_connections has been initialized to 0, why subtract 1 again?Can someone explain it to me?,thanks

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

No branches or pull requests

2 participants