-
Notifications
You must be signed in to change notification settings - Fork 25
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
Reconnection fails on first attempt #5
Comments
I commented out the
|
This is because the connection is marked as active, although closed by the server, and it's not a use case handled by the patch. I added the following at the beginning of the function to handle the case where a connection is obsolete and needs to be closed (provided you have set the if (
self.connection is not None
and self.close_at is not None
and time.monotonic() >= self.close_at
):
_log.debug("closing obsolete connection")
self.close() This won't handle a restarted server, but at least it handles connections closed by the server during a long request. |
I'm running Django and Postgres in two separate Docker containers. If I restart the Postgres container to simulate a connection problem, the connection is only reestablished in a Django shell on the second attempt to run a query.
The text was updated successfully, but these errors were encountered: